2016-12-23 68 views
0

我目前正在嘗試使用libshout構建一個簡單的IceCast供應商。libshout構建未定義的引用SSL_is_init_finished

不幸的是,我無法解決一些鏈接錯誤:

Invoking: Cygwin C++ Linker 
g++ -L"D:\Programme\Cygwin\usr\x86_64-w64-mingw32\sys-root\mingw\include\ogg" -L"D:\Programme\Cygwin\usr\x86_64-w64-mingw32\sys-root\mingw\include" -L"D:\Programme\Cygwin\usr\x86_64-w64-mingw32\sys-root\mingw\include\vorbis" -o "LibshoutJavaAdapter.exe" ./src/LibshoutJavaAdapter.o -lshout -lvorbis -logg -lssl -lcrypto 
/usr/lib/gcc/x86_64-pc-cygwin/5.4.0/../../../../lib/libshout.a(tls.o): In function `tls_setup_process': 
/cygdrive/d/Programme/utility/libshout-2.4.1/src/tls.c:200: undefined reference to `SSL_is_init_finished' 
/cygdrive/d/Programme/utility/libshout-2.4.1/src/tls.c:200:(.text+0x74): relocation truncated to fit: R_X86_64_PC32 against undefined symbol `SSL_is_init_finished' 
/cygdrive/d/Programme/utility/libshout-2.4.1/src/tls.c:203: undefined reference to `SSL_is_init_finished' 
/cygdrive/d/Programme/utility/libshout-2.4.1/src/tls.c:203:(.text+0x8f): relocation truncated to fit: R_X86_64_PC32 against undefined symbol `SSL_is_init_finished' 
/usr/lib/gcc/x86_64-pc-cygwin/5.4.0/../../../../lib/libshout.a(tls.o): In function `tls_setup': 
/cygdrive/d/Programme/utility/libshout-2.4.1/src/tls.c:66: undefined reference to `OPENSSL_init_ssl' 
/cygdrive/d/Programme/utility/libshout-2.4.1/src/tls.c:66:(.text+0x4ad): relocation truncated to fit: R_X86_64_PC32 against undefined symbol `OPENSSL_init_ssl' 
/cygdrive/d/Programme/utility/libshout-2.4.1/src/tls.c:67: undefined reference to `OPENSSL_init_ssl' 
/cygdrive/d/Programme/utility/libshout-2.4.1/src/tls.c:67:(.text+0x4b9): relocation truncated to fit: R_X86_64_PC32 against undefined symbol `OPENSSL_init_ssl' 
/cygdrive/d/Programme/utility/libshout-2.4.1/src/tls.c:68: undefined reference to `SSLeay_add_all_algorithms' 
/cygdrive/d/Programme/utility/libshout-2.4.1/src/tls.c:68:(.text+0x4be): relocation truncated to fit: R_X86_64_PC32 against undefined symbol `SSLeay_add_all_algorithms' 
/cygdrive/d/Programme/utility/libshout-2.4.1/src/tls.c:69: undefined reference to `OPENSSL_init_ssl' 
/cygdrive/d/Programme/utility/libshout-2.4.1/src/tls.c:69:(.text+0x4c7): relocation truncated to fit: R_X86_64_PC32 against undefined symbol `OPENSSL_init_ssl' 
collect2: error: ld returned 1 exit status 

我使用Cygwin的GCC 64位版本,butalso得到了32版的編譯如果需要的話。 構建使用使

我的實際代碼到現在是非常基本的(我只是剛開始使用這個庫)

#include <iostream> 
#include <shout/shout.h> 

int main() { 
    shout_init(); 
    std::cout << "!!!Hello World!!!" << std::endl; // prints !!!Hello World!!! 
    return 0; 
} 

我用下面的程序庫,用於連接在這條命令觸發(-l): 喊 - >實際庫我嘗試使用 Vorbis格式OGG SSL 加密

從我假設錯誤的外觀,這被以某種方式與SSL相關的,但我確實有壽我不是嗎? 我已經嘗試過旋轉順序,但僅創造了更多的錯誤,所以我想的順序是正確的......

編輯1

由於nnovich-OK的建議,我改變了這樣我的代碼檢查的OpenSSL:

#include <iostream> 
//#include <shout/shout.h> 
#include <ctype.h> 
#include <openssl/ssl.h> 

int main() { 
    //shout_init(); 
    OPENSSL_init(); 
    OPENSSL_INIT_SETTINGS * test = NULL; 
    OPENSSL_init_ssl(0,test); 
    //SSL_is_init_finished(); 
    std::cout << "!!!Hello World!!!" << std::endl; // prints !!!Hello World!!! 
    return 0; 
} 

有導致鏈接錯誤是這樣的:

g++ -L"D:\Programme\Cygwin\usr\x86_64-w64-mingw32\sys-root\mingw\include\ogg" -L"D:\Programme\Cygwin\usr\x86_64-w64-mingw32\sys-root\mingw\include" -L"D:\Programme\Cygwin\usr\x86_64-w64-mingw32\sys-root\mingw\include\vorbis" -o "LibshoutJavaAdapter.exe" ./src/LibshoutJavaAdapter.o -lshout -lvorbis -logg -lssl -lcrypto 
./src/LibshoutJavaAdapter.o: In function `main': 
/cygdrive/d/Install und andere Sachen/Eclipse/C++/LibshoutJavaAdapter/Debug/../src/LibshoutJavaAdapter.cpp:18: undefined reference to `OPENSSL_init_ssl' 
/cygdrive/d/Install und andere Sachen/Eclipse/C++/LibshoutJavaAdapter/Debug/../src/LibshoutJavaAdapter.cpp:18:(.text+0x27): relocation truncated to fit: R_X86_64_PC32 against undefined symbol `OPENSSL_init_ssl' 
collect2: error: ld returned 1 exit status 

我發現從ssl.h中有OPENSSL_init_ssl存在問題,但crypto.h中沒有OPENSSL_init(女巫實習生包含在ssl.h中)

這是否給了任何人任何想法?

來解決此問題的任何提示讚賞

+1

Cygwin系統版本的OpenSSL是1.0.2j(在撰寫本文時)。 'SSL_is_init_finished'是OpenSSL 1.1.0的一部分。我沒有看到一個編譯命令,指出您正在使用1.1.0版本。至少,我希望看到類似'-I「D:\ Program \ OpenSSL-1.1.0 \ include」'。你的鏈接命令應該包含'-L「D:\ Program \ OpenSSL-1.1.0 \ lib」'。 – jww

回答

1

我沒有相同的設置來嘗試,但提供的信息似乎很清楚。鏈接器無法從ssl庫中找到函數,所以您需要關注鏈接ssl。我認爲,問題場景可以簡化爲調用OPENSSL_init_ssl()的簡單主函數(參數無關緊要,因爲您不打算執行它)並構建只涉及鏈接openssl的進程。解決此鏈接失敗將有助於解決您當前的情況。所以,讓谷歌和SO與你在一起:)

PS我寧願把所有這些置於評論中,但不允許SO新手。

編輯:

查錯(查看下面註釋)透露實際的根本原因。系統有幾個libssl實例(例如某些應用程序安裝帶來了另一個版本),並且鏈接器使用的實例不適合當前版本(例如構建64位應用程序中的32位版本)。因此,解決方案是將鏈接器放入詳細模式,並檢查庫路徑是否符合預期。

+0

嗨,按照你的建議做出了與我之前經歷的完全相同的錯誤(無論如何,其中之一)。 你有什麼想法,我怎麼可以嘗試解決這個問題,或者至少可以更好地瞭解哪裏出了問題? – Omega1001

+0

那麼,鏈接器不會說「無法找到-lssl」,所以它可以找到lib,但無法獲得必要的符號。我要檢查的第一件事是,libssl是否打算用於與編譯器生成的main.o相同的平臺。這是可能的,該編譯器默認的目標是x64,而openssl的目標是32位或反之亦然。檢查[這裏](http://stackoverflow.com/questions/9260948/how-to-see-the-compilation-platform-of-a-static-library-file)也許[這裏](http:// stackoverflow我碰到了[這個主題](https://www.microsoft.com/downloads/details.aspx?displaylang=zh-cn&id=8659694/how-can-i-tell-whether-my-gcc-is-compiling-64bit-by-default) –

+0

夫妻更多的事情提及: –