本文介绍了链接器在链接* .libs时如何解决模糊?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在非常长的时间花在与未解决的外部后,我发现VS2010链接错误的.lib文件。

after very long long time spent with unresolved externals I found that VS2010 was linking wrong .lib file.

文件遗憾命名具有相同的名称。

Files were unfortunately named with same name.

在项目属性中设置了具有链接(不需要)lib的文件夹
具有未链接(想要)的文件夹lib从其他属性表继承

Folder with linked(unwanted) lib was set in project propertiesFolder with unlinked(wanted) lib was inherited from other property sheet

所需的lib是较新的日期,不需要的日期是非常旧的。

Desired lib was newer date, undesired was very older.

Linker选择了不需要的一个(如上所示)。

Linker chose the unwanted one (as above).

链接库的规则是什么?
不应该链接器至少给出一些歧义的警告吗?

What are the rules for linking libs?Shouldn't linker give at least warning on some ambiguity?

编辑:
符号只在NEW lib中定义。并且只有当我删除OLD lib(没有链接器设置更改)时,才搜索NEW库。

edit:symbol is defined ONLY in NEW lib. And the NEW lib is being searched only when I delete OLD lib (no linker settings changed)

推荐答案

将LIB视为链接器头到编译器。 LIB只有导出符号的签名,除非它是静态LIB。 LIB文件没有附加任何版本

Think of LIBs to Linker as header to compiler. A LIB only has signature of exported symbols, unless it is static LIB. LIB files do not have any version attached to them.

两个LIB文件可以具有相同的名称,因为两个头文件可以具有。它是你,程序员,谁必须使用正确的LIB /头文件。如果链接器没有找到所有符号,或者如果符号不正确,它将报告错误(就像编译器会对头文件中的不一致符号一样)。

Two LIB file can have same name, as two header files can have. It's you, the programmer, who has to use correct LIB/header file. If the linker doesn't find all symbols, or if symbols are not correct, it will report error (just like compiler will do for inconsistent symbols in header file).

这篇关于链接器在链接* .libs时如何解决模糊?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-16 00:14