How linker solves ambiguities when linking *.libs?
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.
Folder with linked(unwanted) lib was set in开发者_运维问答 project properties Folder with unlinked(wanted) lib was inherited from other property sheet
Desired lib was newer date, undesired was very older.
Linker chose the unwanted one (as above).
What are the rules for linking libs? Shouldn't linker give at least warning on some ambiguity?
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)
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.
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).
精彩评论