简体   繁体   English

在Ubuntu 12.04.1 LTS libssl libcrypto上的未定义引用

[英]Undefine references on Ubuntu 12.04.1 LTS libssl libcrypto

I have got a series of errors I have added -l ssl and -l crypto . 我添加了-l ssl and -l crypto导致了一系列错误。 However I do not know which version library I need to install 但是我不知道我需要安装哪个版本库

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

There are numerous options such as 有很多选择,例如

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.

and

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

There are more but I have shortened it. 还有更多,但我已经缩短了。 Could someone please point me in the right direction? 有人能指出我正确的方向吗?

Imagine the (imaginary) linker trying to link these modules: 想象一下(虚构的)链接器试图链接这些模块:

link moda modb modc modd

The linker doesn't (for efficiency reasons) record all the symbols it has seen in moda to try to match them with symbols in modb . 链接器不会(出于效率原因)不记录它在moda中看到的所有符号,以尝试将它们与modb符号匹配。 For example, if moda is a huge library, then the linking process becomes very slow (and memory consuming), if all symbols of moda are remembered throughout the whole process. 例如,如果moda是一个巨大的库,那么如果在整个过程中都记住了moda所有符号,则链接过程将变得非常缓慢(并且消耗内存)。

As a result, the linker always remembers only the (so far) missing symbols and tries to find them in the modules that come afterwards . 结果,链接器始终仅记住(到目前为止)缺少的符号,并尝试在随后的模块中找到它们。 Note that this is only true for libraries. 请注意,这仅适用于库。 This is because objects of the same library/application may have circular dependency. 这是因为同一库/应用程序的对象可能具有循环依赖性。

This means that missing symbols of modb for example, are searched for only in modc and modd and not in moda (again, if moda , modc and modd are libraries). 例如,这意味着仅在modcmodd不是moda中搜索丢失的modb符号(同样,如果modamodcmodd是库)。

Therefore, if you have modx using symbols of mody , then you must mention mody after modx in the link command. 因此,如果你有modx使用的符号mody ,那么就不能不提mody modx在链接命令。

For example, if you have files main.o , funcs.o and libmatrix.a , then you need to write your link command like this: 例如,如果您有文件main.ofuncs.olibmatrix.a ,那么您需要这样编写链接命令:

gcc funcs.o main.o -lmatrix

otherwise, if you write gcc -lmatrix funcs.o main.o , the symbols of libmatrix.a will not be visible to funcs.o and main.o . 否则,如果你写gcc -lmatrix funcs.o main.o的符号libmatrix.a将不可见funcs.omain.o

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM