我添加了-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


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

最佳答案

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

link moda modb modc modd


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

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

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

因此,如果您使用modx符号使用mody,则必须在链接命令中的mody后提及modx

例如,如果您有文件main.ofuncs.olibmatrix.a,则需要这样编写链接命令:

gcc funcs.o main.o -lmatrix


否则,如果您写gcc -lmatrix funcs.o main.o,则libmatrix.afuncs.o将看不见main.o的符号。

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

10-13 06:18