Building Openssl source for compiling boost

2019-07-16 00:09发布

问题:

note. I have seen and read Boost::asio::ssl OpenSSL not compiling

source file

I am having some issues build the boost example ssl server on linux fedora 64 I think its version 15 or 16. It is a university machine so we do not have root access and since is the weekend I am accessing a machine via SSH. We do not have root and openssl is not installed. I built the boost library no program and the example server builds fine. I then tried to build the latest openssl library from source. I extracted to ~/Dev/opensslSource

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

Now either the problem exists there or in how I am including and linking. So then in my boostexamples folder I did saved the example sslserver.cpp And used the following to build.

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

The errors are almost endless. I cant even see them all. But they are all just undefided references I believe.

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'

So after the first few comments I have changed the build to.

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

Error now.

/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:

You are missing a few libraries from your linking options: libssl depends on libcrypto, which in turn depends on libdl. All in all, you will need

-lboost_system -lssl -lcrypto -ldl -lpthread.