views:

533

answers:

1

I have been working through the asio ssl examples (linked below). Despite by best efforts I have been unable to link openssl into the boost example. The output from ld is that ld is missing symbols from libssl.a. The thing that I can not figure out is that I found all the symbols in libssl.a with nm that ld says are missing. I suspect I am doing something dumb but I am not familiar enough with c++ to fix it. I have also included my makefile. The source of ssl-client.cpp is verbatim from the link.

http://www.boost.org/doc/libs/1_41_0/doc/html/boost_asio/example/ssl/client.cpp

INCLUDES = -I /usr/local/boost_1_41_0/ -I /opt/local/include/
LIBS = -L/usr/local/boost_1_41_0/lib/libboost_system.a \
-L/opt/local/lib/libcrypto.a \
-L/opt/local/lib/libssl.a

CPP = g++

build: ssl-client

ssl-client: ssl-client.cpp
    $(CPP) $(LIBS) $(INCLUDES) ssl-client.cpp
+2  A: 

I think you've misunderstood how the -L option works. -L specifies a path in which to search for libraries. To specify an individual library to link to, use the -l option and omit the "lib" prefix, as follows:

LIBS = -L/usr/local/boost_1_41_0/lib -L/opt/local/lib \
    -lboost_system -lcrypto -lssl

Also, there is usually no space between the -I include path option and the actual path. I'm not sure if a space in there causes problems, but you might try this to be on the safe side:

INCLUDES = -I/usr/local/boost_1_41_0/ -I/opt/local/include/

Also, as noted in my comment, you defined the LIBS variable but then used the LIB variable. The call to g++ should be as follows:

$(CPP) $(LIBS) $(INCLUDES) ssl-client.cpp
Martin B
Thanks a million. I knew it was something simple. Now I am one step closer to not being a c++ newb.
kazakdogofspace