These both questions did not solve my problem: glib-undefined-reference-to-anything-from-glib and undefined-reference-to-pthread-create
I am writing a personalized version of the snprintf
function from glibc-2.21. When I want to link my main.o
which is calling the new function snpprintf()
then I receive dozens of undefined reference to
errors from linker for each call/reference of a glibc-2.21 function.
This is the command:
ar rvs libFaFsprintf.a snpprintf.o vfpprintf.o vsnpprintf.o iovspprintf.o
gcc main.o libFaFsprintf.a -lc -o main
I have my object files in the library libFafsprintf.a
- it does not matter if I provide the library or I specify each object file. The source code is compiled without any problem.
I tried also to change the order of my library and -lc
- nothing helps.
It only works when I use the -static
option but I do not want to link libc statically with the executable.
How do I have to link the program?