PDA

View Full Version : -lssl -ldl -lpthread linker flag is not working in ubuntu



syed-raihan
September 19th, 2013, 04:16 AM
I have following linker/compiler command,
LDFLAGS= -lssl -lcrypto -lstdc++ -lpthread -ldl
CXXFLAGS=-c -O2 -std=gnu++11 -pthread -Werror -Wall

However I get SSL_* undefined symbols, pthread_create undefined, and dlopen undefined symbols ..

Same options works fine with Fedora 17. I have all dev files installed in ubuntu.
What is going on in Ubuntu?
Any help please?
Syed Raihan

spjackson
September 21st, 2013, 11:06 AM
Is this make? I think you are supposed to use LDLIBS for libraries, not LDFLAGS.

The reason that your link works on Fedora but not Ubuntu is that on (recent) Ubuntu, ld defaults to --as-needed. You could also probably "fix" it by adding --no-as-needed to your LDFLAGS, but I think that using LDLIBS would be better.