帮助构建 boost asio ssl 示例

发布于 2024-08-19 14:49:52 字数 731 浏览 2 评论 0原文

我一直在研究 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

笑梦风尘 2024-08-26 14:49:52

我认为您误解了 -L 选项的工作原理。 -L 指定搜索库的路径。要指定要链接到的单个库,请使用 -l 选项并省略“lib”前缀,如下所示:

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

此外,-I 之间通常没有空格包括路径选项和实际路径。我不确定其中的空格是否会导致问题,但为了安全起见,您可能会尝试这样做:

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

另外,正如我的评论中所述,您定义了 LIBS 变量,但随后使用了 <代码>LIB变量。对 g++ 的调用应如下所示:

$(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
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文