2012-11-29 85 views
0

我有一系列的錯誤,我添加了-l ssl and -l crypto。但是我不知道我是否需要安裝Ubuntu上的未定義引用12.04.1 LTS libssl libcrypto

/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 

還有更多,但我縮短了它的版本庫。有人能指點我正確的方向嗎?

+2

請將**精確**編譯器調用添加到您的問題。 – Zeta

+0

我已經發現它是我把標誌放在-l ssl等中的順序應該在最後謝謝你的幫助:) – gda2004

+0

可能的重複[Noobish,編譯時針對glib的鏈接器錯誤...? ](http://stackoverflow.com/questions/9966959/noobish-linker-errors-when-compiling-against-glib) – hmjd

回答

1

想象的(虛構的)連接器試圖將這些模塊鏈接:

link moda modb modc modd 

鏈接器不會(出於效率的考慮),它記錄在moda已經看到了所有的符號,試圖用符號與它們匹配modb。例如,如果moda是一個巨大的庫,那麼如果在整個過程中都記住moda的所有符號,則鏈接過程變得非常慢(並且消耗內存)。

因此,鏈接器總是隻記住(到目前爲止)丟失的符號,並試圖在之後的模塊中找到它們。請注意,這隻適用於圖書館。這是因爲相同庫/應用程序的對象可能具有循環依賴性。

這意味着modb去掉的符號,例如,被搜索僅在modcmoddmoda(再次,如果modamodcmodd是庫)。

因此,如果你有modx使用mody符號,則必須modx在鏈接命令後提mody

舉例來說,如果你有文件main.ofuncs.olibmatrix.a,那麼你需要編寫你的鏈接命令是這樣的:否則

gcc funcs.o main.o -lmatrix 

,如果你寫gcc -lmatrix funcs.o main.olibmatrix.a符號將不可見到funcs.omain.o

相關問題