c++ - 构建 Openssl 源代码以编译 boost

标签 c++ boost openssl fedora

注意。我已经看到并阅读过Boost::asio::ssl OpenSSL not compiling

source file

我在 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

最佳答案

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

-lboost_system -lssl -lcrypto -ldl -lpthread

关于c++ - 构建 Openssl 源代码以编译 boost,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14674360/

相关文章:

c++ - std::getline 在 for 循环中不起作用

c++ - 继承错误 "Base Class Unidentified"

c++ - 定义具有相同名称和值的符号字符串常量

c - 如何使用 RSA_generate_key 始终生成不同的公钥

c++ - 混合单独编译的对象

c++ - VC++ 堆栈跟踪不解析生产中的函数名称

c++ - 使用 boost c++ 解析 XML

c++ - Boost 链接、Visual Studio 和版本控制

java - 从 Android 中的 x.509 证书中获取 CA 详细信息

c++ - ECDSA 使用 OpenSSL 签名,使用 Crypto++ 验证