gcc detect duplicate symbols/functions in static libraries

Indeed as Simon Richter stated, --whole-archive option can be useful. Try to change your command-line to:

 gcc -o main main.o util.o -L ./libs -Wl,--whole-archive -lfooutils -Wl,--no-whole-archive

and you’ll see a multiple definition error.

Leave a Comment