帮助建立boost asio ssl示例 [英] Aid in building boost asio ssl example
问题描述
我一直在通过asio ssl示例(链接如下)。尽管最大的努力,我已经无法链接openssl到boost示例。 ld的输出是ld缺少来自libssl.a的符号。我不能想出的事情是,我发现libssl.a中的所有符号与nm,ld说缺失。我怀疑我做一些蠢,但我不熟悉c ++来修复它。我也包括我的makefile。
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
我认为你误解了 -L
选项的工作原理。 -L
指定搜索库的路径。要指定要链接的单个库,请使用 -l </ code>选项并省略lib前缀,如下所示:
LIBS = -L / usr / local / boost_1_41_0 / lib -L / opt / local / lib \
-lboost_system -lcrypto -lssl
另外, -I
include路径选项之间通常没有空格和实际路径。我不知道是否有空间导致问题,但您可以尝试这是安全的一面:
包括= -I / usr / local / boost_1_41_0 / -I / opt / local / include /
如我在注释中所述,您定义了 LIBS
变量,但使用了 LIB
变量。对g ++的调用应该如下:
$(CPP)$(LIBS)$(INCLUDES)ssl-client.cpp
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
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
这篇关于帮助建立boost asio ssl示例的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!