문제

I have a static library exporting the function

time_t SomeClass::getTime();

After compilation its name is mangled as

?getTime@SomeClass@@QAE_JXZ

When I try to use it, VS returns an error

error LNK2001: unresolved external symbol "public: long __thiscall SomeClass::getTime(void)" (?getTime@SomeClass@@QAEJXZ)

And I don't know what is wrong. Why the same function is mangled differently? I've compiled both projects with the same Visual Studio, class has a single header.

Please, help.

도움이 되었습니까?

해결책

The problem was in difference in time_t declarations. Library means it is 64-bit, but application waits for 32-bit value.

The remaining question is "why there is no good documentation for MSVS name mangling"? I've read a lot, but didn't find what is the underline in parameters list.

다른 팁

Have you included the .lib file in your linker INPUT property? In the case you have both two projects in the same solution, you can add the library as a reference to the main project: right click in the main project, and References.

Cheers,

Try to rebuild the whole project. If this does not work, check your Visual Studio Directories (header, libs)

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top