构建用于编译boost的Openssl源代码

时间:2013-02-03 16:01:53

标签: 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

1 个答案:

答案 0 :(得分:2)

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

-lboost_system -lssl -lcrypto -ldl -lpthread