gpt4 book ai didi

c - MinGW/libssl 链接错误

转载 作者:太空宇宙 更新时间:2023-11-03 23:34:45 27 4
gpt4 key购买 nike

我正在将我在 Linux 中开发的应用程序移植到 Windows,但在构建该应用程序时遇到了一些问题。在进行必要的代码更改后,一切都可以正常编译(并且在 Visual Studio 中作为调试版本构建时,运行没有任何问题)。我需要在 MinGW 中构建它,当我尝试将它链接到 liboauth 时出现链接器错误,这也是我的项目所必需的。

命令及其输出如下:

gcc application.o service.o util.o json.o api.o -L/usr/local/lib -lcrypto -lssl -lcurl -ljansson -loauth -Wl -o application

C:/MinGW/msys/1.0/local/lib/liboauth.a(liboauth_la-hash.o): In function `oauth_sign_hmac_sha1_raw':
c:\lib\liboauth-0.9.4\src/hash.c:314: undefined reference to `EVP_sha1'
c:\lib\liboauth-0.9.4\src/hash.c:314: undefined reference to `HMAC'
C:/MinGW/msys/1.0/local/lib/liboauth.a(liboauth_la-hash.o): In function `oauth_sign_rsa_sha1':
c:\lib\liboauth-0.9.4\src/hash.c:334: undefined reference to `BIO_new_mem_buf'
c:\lib\liboauth-0.9.4\src/hash.c:335: undefined reference to `PEM_read_bio_PrivateKey'
c:\lib\liboauth-0.9.4\src/hash.c:336: undefined reference to `BIO_free'
c:\lib\liboauth-0.9.4\src/hash.c:343: undefined reference to `EVP_PKEY_size'
c:\lib\liboauth-0.9.4\src/hash.c:346: undefined reference to `EVP_sha1'
c:\lib\liboauth-0.9.4\src/hash.c:346: undefined reference to `EVP_DigestInit'
c:\lib\liboauth-0.9.4\src/hash.c:347: undefined reference to `EVP_DigestUpdate'
c:\lib\liboauth-0.9.4\src/hash.c:348: undefined reference to `EVP_SignFinal'
c:\lib\liboauth-0.9.4\src/hash.c:352: undefined reference to `CRYPTO_free'
c:\lib\liboauth-0.9.4\src/hash.c:353: undefined reference to `EVP_PKEY_free'
C:/MinGW/msys/1.0/local/lib/liboauth.a(liboauth_la-hash.o): In function `oauth_verify_rsa_sha1':
c:\lib\liboauth-0.9.4\src/hash.c:367: undefined reference to `BIO_new_mem_buf'
c:\lib\liboauth-0.9.4\src/hash.c:368: undefined reference to `PEM_read_bio_X509'
c:\lib\liboauth-0.9.4\src/hash.c:370: undefined reference to `X509_get_pubkey'
c:\lib\liboauth-0.9.4\src/hash.c:371: undefined reference to `X509_free'
c:\lib\liboauth-0.9.4\src/hash.c:375: undefined reference to `BIO_free'
c:\lib\liboauth-0.9.4\src/hash.c:384: undefined reference to `EVP_sha1'
c:\lib\liboauth-0.9.4\src/hash.c:384: undefined reference to `EVP_DigestInit'
c:\lib\liboauth-0.9.4\src/hash.c:385: undefined reference to `EVP_DigestUpdate'
c:\lib\liboauth-0.9.4\src/hash.c:386: undefined reference to `EVP_VerifyFinal'
c:\lib\liboauth-0.9.4\src/hash.c:387: undefined reference to `EVP_MD_CTX_cleanup'
c:\lib\liboauth-0.9.4\src/hash.c:388: undefined reference to `EVP_PKEY_free'
c:\lib\liboauth-0.9.4\src/hash.c:373: undefined reference to `PEM_read_bio_PUBKEY'
C:/MinGW/msys/1.0/local/lib/liboauth.a(liboauth_la-hash.o): In function `oauth_body_hash_file':
c:\lib\liboauth-0.9.4\src/hash.c:405: undefined reference to `EVP_MD_CTX_init'
c:\lib\liboauth-0.9.4\src/hash.c:406: undefined reference to `EVP_sha1'
c:\lib\liboauth-0.9.4\src/hash.c:406: undefined reference to `EVP_DigestInit'
c:\lib\liboauth-0.9.4\src/hash.c:408: undefined reference to `EVP_DigestUpdate'
c:\lib\liboauth-0.9.4\src/hash.c:412: undefined reference to `EVP_sha1'
c:\lib\liboauth-0.9.4\src/hash.c:412: undefined reference to `EVP_MD_size'
c:\lib\liboauth-0.9.4\src/hash.c:413: undefined reference to `EVP_DigestFinal'
c:\lib\liboauth-0.9.4\src/hash.c:414: undefined reference to `EVP_MD_CTX_cleanup'
C:/MinGW/msys/1.0/local/lib/liboauth.a(liboauth_la-hash.o): In function `oauth_body_hash_data':
c:\lib\liboauth-0.9.4\src/hash.c:422: undefined reference to `EVP_sha1'
c:\lib\liboauth-0.9.4\src/hash.c:422: undefined reference to `EVP_MD_size'
c:\lib\liboauth-0.9.4\src/hash.c:423: undefined reference to `EVP_MD_CTX_init'
c:\lib\liboauth-0.9.4\src/hash.c:424: undefined reference to `EVP_sha1'
c:\lib\liboauth-0.9.4\src/hash.c:424: undefined reference to `EVP_DigestInit'
c:\lib\liboauth-0.9.4\src/hash.c:425: undefined reference to `EVP_DigestUpdate'
c:\lib\liboauth-0.9.4\src/hash.c:426: undefined reference to `EVP_DigestFinal'
c:\lib\liboauth-0.9.4\src/hash.c:427: undefined reference to `EVP_MD_CTX_cleanup'
collect2: ld returned 1 exit status
make: *** [montools] Error 1

我在 lib 路径中有所有必需的库,但出于某种原因,liboauth 找不到对 libssl 和 libcrypto 的引用。这一切都在 Linux 中构建得很好。有什么想法吗?

更新

根据回复,我更新了链接器命令,以便以不同的顺序链接库。我的新命令如下:

gcc -o application application.o service.o util.o json.o api.o -Lc:/mingw/msys/1.0/local/lib -loauth -ljansson -lcurl -lssl -lcrypto

这解决了之前的问题并出现了一组新的链接器错误:

gcc -o application application.o service.o util.o json.o api.o -Lc:/mingw/msys/1.0/local/lib -loauth -ljansson -lcurl -lssl -lcrypto 
c:/mingw/bin/../lib/gcc/mingw32/4.5.2/../../../libcrypto.a(rand_win.o):rand_win.c:(.text+0xee0): undefined reference to `CreateDCA@16'
c:/mingw/bin/../lib/gcc/mingw32/4.5.2/../../../libcrypto.a(rand_win.o):rand_win.c:(.text+0xeef): undefined reference to `CreateCompatibleDC@4'
c:/mingw/bin/../lib/gcc/mingw32/4.5.2/../../../libcrypto.a(rand_win.o):rand_win.c:(.text+0xf08): undefined reference to `GetDeviceCaps@8'
c:/mingw/bin/../lib/gcc/mingw32/4.5.2/../../../libcrypto.a(rand_win.o):rand_win.c:(.text+0xf23): undefined reference to `GetDeviceCaps@8'
c:/mingw/bin/../lib/gcc/mingw32/4.5.2/../../../libcrypto.a(rand_win.o):rand_win.c:(.text+0xf44): undefined reference to `CreateCompatibleBitmap@12'
c:/mingw/bin/../lib/gcc/mingw32/4.5.2/../../../libcrypto.a(rand_win.o):rand_win.c:(.text+0xf5b): undefined reference to `SelectObject@8'
c:/mingw/bin/../lib/gcc/mingw32/4.5.2/../../../libcrypto.a(rand_win.o):rand_win.c:(.text+0xf7e): undefined reference to `GetObjectA@12'
c:/mingw/bin/../lib/gcc/mingw32/4.5.2/../../../libcrypto.a(rand_win.o):rand_win.c:(.text+0x1024): undefined reference to `BitBlt@36'
c:/mingw/bin/../lib/gcc/mingw32/4.5.2/../../../libcrypto.a(rand_win.o):rand_win.c:(.text+0x103b): undefined reference to `GetBitmapBits@12'
c:/mingw/bin/../lib/gcc/mingw32/4.5.2/../../../libcrypto.a(rand_win.o):rand_win.c:(.text+0x10b0): undefined reference to `SelectObject@8'
c:/mingw/bin/../lib/gcc/mingw32/4.5.2/../../../libcrypto.a(rand_win.o):rand_win.c:(.text+0x10bb): undefined reference to `DeleteObject@4'
c:/mingw/bin/../lib/gcc/mingw32/4.5.2/../../../libcrypto.a(rand_win.o):rand_win.c:(.text+0x10c8): undefined reference to `DeleteDC@4'
c:/mingw/bin/../lib/gcc/mingw32/4.5.2/../../../libcrypto.a(rand_win.o):rand_win.c:(.text+0x10d5): undefined reference to `DeleteDC@4'
collect2: ld returned 1 exit status
make: *** [montools] Error 1

快速谷歌搜索返回我还应该链接到 gdi32 库(用于与我的任务无关的目的。链接器的最终命令如下:

gcc -o application application.o service.o util.o json.o api.o -Lc:/mingw/msys/1.0/local/lib -loauth -ljansson -lcurl -lssl -lcrypto -lgdi32

最佳答案

试试这个:

gcc -o application application.o service.o util.o json.o api.o -Lc:/mingw/msys/1.0/local/lib -loauth -ljansson -lcurl -lssl -lcrypto 

关于c - MinGW/libssl 链接错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7068620/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com