Search code examples
c++hyperlinksymbolslnk2019missing-symbols

MSVC2019 Missing symbol names from static library


I'm newbe with C++ please help me if someone can!

I've made a binary bigint object which work well. I complied it to a static library and tried to include into an another program but it fails with errors like this:

combinations.obj||error LNK2019: unresolved external symbol "public: static void __cdecl BinBigInt::bifactorial(class BinBigInt const &,class BinBigInt &)" (?bifactorial@BinBigInt@@SAXAEBV1@AEAV1@@Z) referenced in function "unsigned __int64 __cdecl combi::nonrepCombination(char,char,class std::basic_string,class std::allocator >)" (??$nonrepCombination@D@combi@@YA_KDDV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@Z)|

If i copy paste the two code together everything is work well so the codes seems to be OK.

I read a lot of topics about the LNK2019 error and checked the compiler settings and Release vs. Debug version matching and so on but nothing helped.

At last I checked the symbols in the .lib file manually with MS dumpbin as guessed in some topic to check name manling problems but I found that a lot of (9) function name and all (7) of internally defined operators really not contained by the .lib file. (compiler just pop up 5 unresolved external symbol error those thats which I really tryed to used in the implementing file.)

It seems to be not just a name manling problem I absolutely not found those symbol names with dumpbin.

While lot of other functions which defined inside the object and operators (like Comparisson, bitwise etc.) which defined out of the object is contained by the .lib file.

I used: dumpbin /symbols binbigint.lib | findstr "function name" in a lot of version to check them.

I use Code::Blocks with MSVC2019 host and target both x64.

Someone have any guess what can couse that the lib didn't contain some symbols?

(The library code is about 3.000 row long so I didn't copy here...)


Solution

  • Well. I found the problem...

    That was me... :(

    Originally I've wrote the whole object declaration and definition inside the object scope in a .cpp file. And it worked well. And I thought will be enough to delete the implementetion parts in the header and I can leaving the whole class code with the class header in the .cpp too and I forget include the .h to the .cpp so compiler not generated errors about it.

    The fact that it works with Copy paste put me on the right track (that must be some problem with the .h+.cpp version) at the end.

    Sorry for disturbing!

    (This was my first class which I try to use as .lib)