I am trying to compile a C program while linking dynamically libcurl and statically libc.
My Makefile looks like:
SRC=myprogram.c
LDFLAGS+= -static libc.a -static-libgcc -Wl,-static -lc
LDFLAGS+= -linfluxdb -lcurl -lm -ljson-c
I need to link libc dynamically because libc version is not the same between centos7 and centos6, so I will include the chosen one in the binary. I could have linking everything statically but it's not working for libcurl; I am having errors in the linker resolving several libcurl functions. I tried to add "dynamic" flag for libcurl
LDFLAGS+= -Wl,-Bdynamic -lcurl
But I still have a dynamic reference to libc. Ldd outputs:
libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007ff3811b2000)
Through this question (Static linking libcurl using c) I knew that libcurl depends on libc. Is it a way to force the usage of static libc everywhere ?