将 *.lib 文件与 MinGW 链接
是否可以将 *.lib
文件与 MinGW 链接(我将其与 Eclipse 一起使用)?
我正在与 libcurl+OpenSSL 进行斗争,我不明白我的错误是否是因为我尝试在 MinGW 中使用 .lib
-files 或者其他错误:
..\lib/libeay32.lib(tmp32/asn_mime.obj):(.text[_SMIME_text]+0x6): undefined reference to `_chkstk'
..\lib/libeay32.lib(tmp32/asn_mime.obj):(.text[_SMIME_text]+0xb): undefined reference to `__security_cookie'
..\lib/libeay32.lib(tmp32/asn_mime.obj):(.text[_SMIME_text]+0x63): undefined reference to `@__security_check_cookie@4'
..\lib/libeay32.lib(tmp32/asn_mime.obj):(.text[_SMIME_text]+0x19e): undefined reference to `@__security_check_cookie@4'
..\lib/libeay32.lib(tmp32/ech_ossl.obj):(.text[_ecdh_compute_key]+0x6): undefined reference to `_chkstk'
..\lib/libeay32.lib(tmp32/bio_asn1.obj):(.text[_asn1_bio_set_ex]+0x6): undefined reference to `_chkstk'
..\lib/libeay32.lib(tmp32/bio_asn1.obj):(.text[_asn1_bio_get_ex]+0x6): undefined reference to `_chkstk'
..\lib/libeay32.lib(tmp32/bio_asn1.obj):(.text[_BIO_asn1_set_prefix]+0x6): undefined reference to `_chkstk'
..\lib/libeay32.lib(tmp32/bio_asn1.obj):(.text[_BIO_asn1_get_prefix]+0x6): undefined reference to `_chkstk'
..\lib/libeay32.lib(tmp32/bio_asn1.obj):(.text[_BIO_asn1_set_suffix]+0x6): more undefined references to `_chkstk' follow
..\lib/ssleay32.lib(tmp32/ssl_lib.obj):(.text[_SSL_has_matching_session_id]+0xb): undefined reference to `__security_cookie'
Is it possible to Link *.lib
files with MinGW (I use it with Eclipse)?
I'm fighting with libcurl+OpenSSL and I don't understand if my errors are because I try to use .lib
-files in MinGW or something else is wrong:
..\lib/libeay32.lib(tmp32/asn_mime.obj):(.text[_SMIME_text]+0x6): undefined reference to `_chkstk'
..\lib/libeay32.lib(tmp32/asn_mime.obj):(.text[_SMIME_text]+0xb): undefined reference to `__security_cookie'
..\lib/libeay32.lib(tmp32/asn_mime.obj):(.text[_SMIME_text]+0x63): undefined reference to `@__security_check_cookie@4'
..\lib/libeay32.lib(tmp32/asn_mime.obj):(.text[_SMIME_text]+0x19e): undefined reference to `@__security_check_cookie@4'
..\lib/libeay32.lib(tmp32/ech_ossl.obj):(.text[_ecdh_compute_key]+0x6): undefined reference to `_chkstk'
..\lib/libeay32.lib(tmp32/bio_asn1.obj):(.text[_asn1_bio_set_ex]+0x6): undefined reference to `_chkstk'
..\lib/libeay32.lib(tmp32/bio_asn1.obj):(.text[_asn1_bio_get_ex]+0x6): undefined reference to `_chkstk'
..\lib/libeay32.lib(tmp32/bio_asn1.obj):(.text[_BIO_asn1_set_prefix]+0x6): undefined reference to `_chkstk'
..\lib/libeay32.lib(tmp32/bio_asn1.obj):(.text[_BIO_asn1_get_prefix]+0x6): undefined reference to `_chkstk'
..\lib/libeay32.lib(tmp32/bio_asn1.obj):(.text[_BIO_asn1_set_suffix]+0x6): more undefined references to `_chkstk' follow
..\lib/ssleay32.lib(tmp32/ssl_lib.obj):(.text[_SSL_has_matching_session_id]+0xb): undefined reference to `__security_cookie'
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
mingw 还接受扩展名为 .lib 的库。
例如,一个名为
库样本库
必须链接为
-L -llibsample
参考:
http://www.mingw.org/wiki/Specify_the_libraries_for_the_linker_to_use
mingw also accepts libraries with a .lib extension.
For instance, a library named
libsample.lib
must be linked as
-L -llibsample
Reference:
http://www.mingw.org/wiki/Specify_the_libraries_for_the_linker_to_use
新的 mingw 版本支持链接 lib 文件。但我遇到了 .lib 带有前缀 libxxxx.lib 的问题。它在链接中省略了前缀 lib。所以让它像 lib<name>.lib
另外还有一些方法可以将 .lib 转换为 .a ex: lib2a
您也可以使用它。
New mingw versions support linking lib files. But I faced issues where .lib is with prefix libxxxx.lib. It omits the prefix lib in linking. So make it like lib<name>.lib
Also there are ways to convert a .lib to .a ex: lib2a
You can use that as well.
可能不会。 mingw的静态库格式是*.a。
给定平台的动态库由必须能够加载它们的操作系统加载器标准化。
静态库只需被工具链的链接器理解,因此交叉编译器的兼容性较差。 Afaik *.lib 文件甚至不兼容所有 MSVC 版本。
由于评论纠缠,稍后添加:
较新版本的 mingw 也支持 .lib 文件,但您早在 11 年就提出了问题,然后您可能就不会再拥有它们了。
Probably not. mingw's static library format is *.a.
Dynamic libraries for a given platform are standardized by the OS loader that must be able to load them.
Static libraries only have to be understood by the toolchain's linker, and are thus less cross compiler compatible. Afaik *.lib files are not even compatible across all MSVC versions.
Added later due to pestering comments:
Newer versions of mingw also support .lib files, but you asked your question back in '11, and then you probably wouldn't have them then.