Linker (ld v2.23.2 from MinGW) error at form: -L<SOMEDIR> -l<lib1 -l<lib2>,

扶醉桌前 提交于 2020-01-17 05:12:25

问题


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.


回答1:


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.



来源:https://stackoverflow.com/questions/29271479/linker-ld-v2-23-2-from-mingw-error-at-form-lsomedir-llib1-llib2

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!