Domanda

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.

È stato utile?

Soluzione

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.

Altri suggerimenti

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)

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top