Brenton Thomas
Brenton Thomas

Reputation: 638

How do you read MSVC C++ Linkage Errors

Can Someone explain to me how to read MSVC linkage errors in general.

An example is one I have just hit which I know means that somewhere in my code I am attempting to link something dynamically that isn't there.

What I would like to understand is how to read the error message properly so I can work out exactly which module I have left a dllimport on in.

Error LNK2019 unresolved external symbol "__declspec(dllimport) public: enum SILLY::PixelFormat __cdecl SILLY::Image::getSourcePixelFormat(void)const " (__imp_?getSourcePixelFormat@Image@SILLY@@QEBA?AW4PixelFormat@2@XZ) referenced in function "public: virtual class CEGUI::Texture * __cdecl CEGUI::SILLYImageCodec::load(class CEGUI::RawDataContainer const &,class CEGUI::Texture *)" (?load@SILLYImageCodec@CEGUI@@UEAAPEAVTexture@2@AEBVRawDataContainer@2@PEAV32@@Z) helloworldui C:\Users\XXXXXX\Documents\Audio Development\evil-sounds\build\helloworldui\cegui64sd.lib(ImageCodec.cpp.obj) 1

I think it means that CEGUI::SILLYImageCodec::load is trying to load SILLY:Image::getSourcePixelFormat as a dll when I want it to load a static library.

The load@SILLYImageCodec@CEGUI@@UEAAPEAVTexture@2@AEBVRawDataContainer@2@PEAV32@@Z bit is throwing me off - it seems backwards.

Upvotes: 2

Views: 141

Answers (2)

Niall
Niall

Reputation: 30604

It means the function SILLY::Image::getSourcePixelFormat called (or otherwise referenced) in the function CEGUI::SILLYImageCodec::load cannot be found by the linker.

The error has little to do with the static vs. import library, it can't be found in any library it has looked in. If it can't be found the linker will produce the same error irrespective of where you intended the function to be. You get the error because you have probably not supplied the linker with the library you want it to use (from what you say, this is the likely error, but it could be caused by a whole host of reasons; see here for more).

The name mangling can be cumbersome, unless you want to write a name demangler, you can generally ignore it (look for the pretty print names instead).

Upvotes: 2

spencercw
spencercw

Reputation: 3358

The bit with all the '@' signs is the mangled name. You can generally ignore this as the linker has already demangled it for you. It looks like the dllimport is attached to the SILLY::Image class, probably in the form of a macro between 'class' and the class name.

Upvotes: 0

Related Questions