c++ - 在 Ubuntu 12.04.1 LTS libssl libcrypto 上取消定义引用

标签 c++ linker ubuntu-12.04

我在添加 -l ssl 和 -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

还有很多,但我已经缩短了。有人可以指出我正确的方向吗?

最佳答案

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

link moda modb modc modd

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

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

这意味着例如 modb 的缺失符号仅在 modcmodd 中搜索,moda 中(同样,如果 modamodcmodd 是库)。

因此,如果您有 modx 使用 mody 的符号,那么您必须在 之后提及 mody >modx 在链接命令中。

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

gcc funcs.o main.o -lmatrix

否则,如果您编写 gcc -lmatrix funcs.o main.olibmatrix.a 的符号将对 funcs.o< 不可见main.o

关于c++ - 在 Ubuntu 12.04.1 LTS libssl libcrypto 上取消定义引用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13625700/

相关文章:

c++ - Boost::Test:编译并运行一个 "hello world"程序

c++ - 为什么计算不对?

c++ - 在 make 文件中链接 g++ 和 lib 不起作用

c++ - 如何让 boost::serialization 工作?

c++ - Qt QFrame成为独立窗口

c++ - 静态链接 boost program_options

c++ - C 函数 **ntohl** 给出链接器错误(未解析的外部)

java - Eclipse 说 "Update Android Developer Toolkit"

python-2.7 - 如何在 Ubuntu12.0.4 LTS 中将 python2.7.3 更新为 python2.7.6

c++ - War Card Game Shuffle 函数返回负 #'s