帮助构建 boost asio ssl 示例
我一直在研究 asio ssl 示例(链接如下)。尽管尽了最大努力,我还是无法将 openssl 链接到 boost 示例中。 ld 的输出是 ld 缺少 libssl.a 中的符号。我无法弄清楚的是,我发现 libssl.a 中带有 nm 的所有符号都丢失了。我怀疑我在做一些愚蠢的事情,但我对 C++ 不够熟悉来解决它。我还包括了我的 makefile。 ssl-client.cpp 的来源是链接中的逐字来源。
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 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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我认为您误解了
-L
选项的工作原理。-L
指定搜索库的路径。要指定要链接到的单个库,请使用-l
选项并省略“lib”前缀,如下所示:此外,
-I
之间通常没有空格包括路径选项和实际路径。我不确定其中的空格是否会导致问题,但为了安全起见,您可能会尝试这样做:另外,正如我的评论中所述,您定义了 LIBS 变量,但随后使用了 <代码>LIB变量。对 g++ 的调用应如下所示:
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: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:Also, as noted in my comment, you defined the
LIBS
variable but then used theLIB
variable. The call to g++ should be as follows: