I am using Visual Studio 5.0 I have DLL and a static library . My intention is to use a static function that is defined in the static library . I have included the header file in the intended source cpp and also given the path in t开发者_如何学JAVAhe project dependencies . Still it gives me linker errors .
Following is the linker error
error LNK2019: unresolved external symbol "public: static bool __cdecl gph::IsA(class PtOnDemand &,wchar_t const *)" (?IsA@gph@@SA_NAAVPtOnDemand@@PB_W@Z) referenced in function "private: int __thiscall PtXMLP::HandleObjectBegin(char const *,char const * *)" (?HandleObjectBegin@PtXMLP@@AAEHPBDPAPBD@Z) 1>.\ReleaseU/epptxml.dll : fatal error LNK1120: 1 unresolved externals
Any suggestions
It could be that the linker is not finding your function because it is compiled with different settings. Like release vs debug, unicode vs non-unicode, differences in calling conventions. That may cause the name to be mangled differently. If the .h file is written in c, not c++, you might need to disable name mangling altogether by wrapping the prototypes in
extern "C"
{
// function prototypes go here.
}
You also have to include the lib file to your project in order for it to be linked in. Note sure about VS5 but on 6 this is under Project / Add to Project / Files. Alternatively, you could include it under linker options in your project properties.
Well, I don't know exactly about Visual Studio 5. But you have to add the library that you want to link statically as additional dependency to your project.
First of all, its time to get a new version of Visual Studio :-) But its likely that you are using it for legacy support.
Anyway, just including the header file isn't enough. You also need to make sure you tell the linker where the static library file is (should be a .a file perhaps) and what the name of the library is.
精彩评论