2

笔记。我已经看到并阅读了 Boost::asio::ssl OpenSSL not compile

源文件

我在 linux fedora 64 上构建 boost 示例 ssl 服务器时遇到了一些问题,我认为它的版本是 15 或 16。它是一台大学机器,所以我们没有 root 访问权限,因为周末我通过 SSH 访问机器。我们没有root,也没有安装openssl。我没有构建boost库,示例服务器构建良好。然后我尝试openssl从源代码构建最新的库。我提取到~/Dev/opensslSource

Cd ~/Dev/opensslSource
 ./config --prefix=~/Dev/openssl --openssldir=~/Dev/openssl
Make
Make install

现在问题存在于那里或我如何包含和链接。所以然后在我的 boostexamples 文件夹中,我确实保存了示例sslserver.cpp 并使用以下内容进行构建。

g++ -I ~/Dev/boost_1_52_0/ -I ~/Dev/openssl/include -L ~/Dev/boost_1_52_0/stage/lib -L ~/Dev/openssl server.cpp -o server -lboost_system -lssl –lpthread

错误几乎是无穷无尽的。我什至都看不到他们。但我相信它们都只是不明确的参考。

d1_enc.c:(.text+0x10c): undefined reference to `EVP_MD_size'
d1_enc.c:(.text+0x12f): undefined reference to `EVP_CIPHER_CTX_cipher'
d1_enc.c:(.text+0x155): undefined reference to `EVP_CIPHER_block_size'
d1_enc.c:(.text+0x1b2): undefined reference to `EVP_Cipher'
d1_enc.c:(.text+0x2cf): undefined reference to `EVP_Cipher'
d1_enc.c:(.text+0x34b): undefined reference to `EVP_CIPHER_block_size'
d1_enc.c:(.text+0x363): undefined reference to `EVP_CIPHER_block_size'
d1_enc.c:(.text+0x375): undefined reference to `RAND_bytes'

因此,在前几条评论之后,我将构建更改为。

g++ -I ~/Dev/boost_1_52_0/ -I ~/Dev/openssl/include -L ~/Dev/boost_1_52_0/stage/lib –L ~/Dev/openssl/lib server.cpp -o server -lboost_system -lssl -lcrypto -lpthread

现在出错。

/home/andrew/Dev/openssl/lib/libcrypto.a(dso_dlfcn.o): In function `dlfcn_globallookup':
dso_dlfcn.c:(.text+0x1d): undefined reference to `dlopen'
dso_dlfcn.c:(.text+0x33): undefined reference to `dlsym'
dso_dlfcn.c:(.text+0x3d): undefined reference to `dlclose'
/home/andrew/Dev/openssl/lib/libcrypto.a(dso_dlfcn.o): In function `dlfcn_bind_func':
dso_dlfcn.c:(.text+0x381): undefined reference to `dlsym'
dso_dlfcn.c:(.text+0x460): undefined reference to `dlerror'
/home/andrew/Dev/openssl/lib/libcrypto.a(dso_dlfcn.o): In function `dlfcn_bind_var':
dso_dlfcn.c:(.text+0x4e1): undefined reference to `dlsym'
dso_dlfcn.c:(.text+0x5c0): undefined reference to `dlerror'
/home/andrew/Dev/openssl/lib/libcrypto.a(dso_dlfcn.o): In function `dlfcn_load':
dso_dlfcn.c:(.text+0x637): undefined reference to `dlopen'
dso_dlfcn.c:(.text+0x6ae): undefined reference to `dlclose'
dso_dlfcn.c:(.text+0x6e5): undefined reference to `dlerror'
/home/andrew/Dev/openssl/lib/libcrypto.a(dso_dlfcn.o): In function `dlfcn_pathbyaddr':
dso_dlfcn.c:(.text+0x781): undefined reference to `dladdr'
dso_dlfcn.c:(.text+0x7e9): undefined reference to `dlerror'
/home/andrew/Dev/openssl/lib/libcrypto.a(dso_dlfcn.o): In function `dlfcn_unload':
dso_dlfcn.c:(.text+0x84a): undefined reference to `dlclose'
collect2: ld returned 1 exit status
4

1 回答 1

2

您的链接选项中缺少一些库:libssl 依赖于 libcrypto,而后者又依赖于 libdl。总而言之,你需要

-lboost_system -lssl -lcrypto -ldl -lpthread.

于 2013-02-03T16:30:09.527 回答