链接器(来自MinGW的ld v2.23.2)错误:-L< SOMEDIR> -l< lib1 -l< lib2&gt ;, [英] Linker (ld v2.23.2 from MinGW) error at form: -L<SOMEDIR> -l<lib1 -l<lib2>,

查看:169
本文介绍了链接器(来自MinGW的ld v2.23.2)错误:-L< SOMEDIR> -l< lib1 -l< lib2&gt ;,的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有ld v2.23.2从mingw-builds 4.8.0 32位套件。在我的项目中的目录中有libs:libitpp.a和libitpp.dll.a。第一个是简单的静态库,第二个是导入库到相应的共享库(在Windows上的DLL)。



我告诉链接器链接有以下形式的libs:
-L ​​$$ ITPP_DIR / libs -litpp
,链接器总是选择第二个lib(libitpp.dll.a),但我想要第一个(libitpp.a),因为-litpp 。



在显式指令:
$$ ITPP_DIR / libs / libitpp.a
all Ok。



在-llib指令下,链接器使用什么规则来查找库?



提前感谢。


<这可能是一个重复的问题,但不是怨声载道,我只是再次给你文档链接: /sourceware.org/binutils/docs/ld/WIN32.html#WIN32rel =nofollow> https://sourceware.org/binutils/docs/ld/WIN32.html#WIN32



有关资料会在直接连接dll的分目下找到;注意,当两者都存在时,ld将总是喜欢libfoo.dll.a到libfoo.a,除非你为-lfoo指定-Bstatic,或者对所有这些模糊的-l指定更常用-static。


Have ld v2.23.2 from mingw-builds 4.8.0 32bit suite. In my project in a directory there are libs: libitpp.a and libitpp.dll.a. The first is simply static lib, the second is import library to correspondent shared lib (DLL on Windows).

I tell linker to link there libs in following form: -L$$ITPP_DIR/libs -litpp and the linker always chooses the second lib (libitpp.dll.a), but I want the first (libitpp.a), because "-litpp" matches it exactly.

At explicit instruction: $$ITPP_DIR/libs/libitpp.a all Ok.

What are the rules linker use to find libraries at -l"lib" instruction?

Thanks in advance.

解决方案

This is probably a duplicate question, but rather than berate you for that, I'll just give you the documentation link again: https://sourceware.org/binutils/docs/ld/WIN32.html#WIN32

The relevant info will be found under the subhead "direct linking to a dll"; notice that ld will always prefer libfoo.dll.a to libfoo.a when both are present, unless you specify -Bstatic for -lfoo, or more generally -static for all such ambiguous -l specifications.

这篇关于链接器(来自MinGW的ld v2.23.2)错误:-L&lt; SOMEDIR&gt; -l&lt; lib1 -l&lt; lib2&gt ;,的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆