在Ubuntu 12.04.1 LTS libssl libcrypto上重新定义引用

时间:2012-11-29 12:19:33

标签: c++ linker ubuntu-12.04

我添加了一系列错误-l ssl and -l crypto。但是我不知道我需要安装哪个版本库

/usr/include/boost/asio/ssl/detail/openssl_init.hpp:48: undefined reference to `SSL_library_init'
/usr/include/boost/asio/ssl/detail/openssl_init.hpp:49: undefined reference to `SSL_load_error_strings'
/usr/include/boost/asio/ssl/detail/openssl_init.hpp:50: undefined reference to `SSL_library_init'
/usr/include/boost/asio/ssl/detail/openssl_init.hpp:52: undefined reference to `CRYPTO_num_locks'
/usr/include/boost/asio/ssl/detail/openssl_init.hpp:55: undefined reference to `CRYPTO_set_locking_callback'
/usr/include/boost/asio/ssl/detail/openssl_init.hpp:56: undefined reference to `CRYPTO_set_id_callback'
/usr/include/boost/asio/ssl/detail/openssl_init.hpp:48: undefined reference to `SSL_library_init'
/usr/include/boost/asio/ssl/detail/openssl_init.hpp:49: undefined reference to `SSL_load_error_strings'

有很多选项,例如

Note, selecting 'libss7-dbg' for regex 'libssl*'
Note, selecting 'libssl0.9.8-dbg' for regex 'libssl*'
Note, selecting 'libss7-dev' for regex 'libssl*'
Note, selecting 'libssl0.9.8' for regex 'libssl*'
Note, selecting 'libss2' for regex 'libssl*'
Note, selecting 'libssm-dev' for regex 'libssl*'
Note, selecting 'libssl' for regex 'libssl*'
Note, selecting 'libssh-4' for regex 'libssl*'
Note, selecting 'libssh-2-dev' for regex 'libssl*'
Note, selecting 'libssh-2-doc' for regex 'libssl*'
Note, selecting 'libssl1.0.0' for regex 'libssl*'
Note, selecting 'libsscm3' for regex 'libssl*'
Note, selecting 'libssl-ocaml-dev' instead of 'libssl-ocaml-dev-l8h98'
Note, selecting 'libssl-ocaml' instead of 'libssl-ocaml-l8h98'
Note, selecting 'libssreflect-ocaml' instead of 'libssreflect-ocaml-kevs8'
Note, selecting 'libssreflect-ocaml-dev' instead of 'libssreflect-ocaml-dev-kevs8'
Note, selecting 'python-libssh2' instead of 'python2.7-libssh2'
libss2 is already the newest version.

Note, selecting 'libcryptokit-ocaml' for regex 'libcrypto*'
Note, selecting 'libcryptokit-ocaml-02n31' for regex 'libcrypto*'
Note, selecting 'libcryptgps-ocaml-dev' for regex 'libcrypto*'
Note, selecting 'libcrypt-blowfish-perl' for regex 'libcrypto*'
Note, selecting 'libcrypt-saltedhash-perl' for regex 'libcrypto*'
Note, selecting 'libcrypt-gcrypt-perl' for regex 'libcrypto*'
Note, selecting 'libcryptui' for regex 'libcrypto*'
Note, selecting 'libcrypt-generatepassword-perl' for regex 'libcrypto*'
Note, selecting 'libcrypt-dh-gmp-perl' for regex 'libcrypto*'
Note, selecting 'libcrypt-cbc-perl' for regex 'libcrypto*'
Note, selecting 'libcrypt-dsa-perl' for regex 'libcrypto*'
Note, selecting 'libcrypt-dh-perl' for regex 'libcrypto*'
Note, selecting 'libcrypt-openssl-bignum-perl' for regex 'libcrypto*'
Note, selecting 'libcryptgps-ocaml-dev' instead of 'libcryptgps-ocaml-dev-1zmb9'
Note, selecting 'libcryptokit-ocaml' instead of 'libcryptokit-ocaml-02n31'
Note, selecting 'libcryptokit-ocaml-dev' instead of 'libcryptokit-ocaml-dev-02n31'

g++ -pthread -l ssl -lcrypto IpcManagerMain.cpp -o IpcManagerMain.o  -lentity++ -lpersistence++ -lplatform++ -lreflection++ -lmonitor++ -lmeta++ -lipc++ -lbroadcast++ -lutilities++ -L/usr/lib          -lboost_serialization -lboost_thread-mt -lboost_date_time -lboost_iostreams -lboost_program_options -lboost_filesystem -lboost_system

还有更多,但我缩短了它。有人可以指点我正确的方向吗?

1 个答案:

答案 0 :(得分:1)

想象一下(想象的)链接器试图链接这些模块:

link moda modb modc modd

链接器不会(出于效率原因)记录它在moda中看到的所有符号,以尝试将它们与modb中的符号进行匹配。例如,如果moda是一个巨大的库,那么如果在整个过程中记住moda的所有符号,则链接过程会变得非常慢(并且消耗内存)。

因此,链接器始终只记住(到目前为止)丢失的符号,并尝试在之后的模块中找到它们。请注意,这仅适用于库。这是因为相同库/应用程序的对象可能具有循环依赖性。

这意味着modb的缺失符号仅在modcmodd以及moda中的而非中进行搜索,如果modamodcmodd是图书馆。)

因此,如果modx使用mody的符号,则必须在链接命令中 mody之后提及modx 。< / p>

例如,如果您有文件main.ofuncs.olibmatrix.a,那么您需要编写链接命令,如下所示:

gcc funcs.o main.o -lmatrix

否则,如果您撰写gcc -lmatrix funcs.o main.o,则libmatrix.afuncs.o将无法看到main.o的符号。