Page 1 of 1

Unresolved external symbol when compiling with static libs

Posted: Mon Apr 19, 2010 17:50
by djzmo
Hello there,

I got those linker errors:

Code: Select all

CGameCanvas.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: __thiscall CEGUI::String::~String(void)" (__imp_??1String@CEGUI@@QAE@XZ) referenced in function "public: __thiscall CGameCanvas::CGameCanvas(class wxWindow *,int,class wxPoint const &,class wxSize const &,long)" (??0CGameCanvas@@QAE@PAVwxWindow@@HABVwxPoint@@ABVwxSize@@J@Z)
CGameCanvas.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: static class CEGUI::System & __cdecl CEGUI::System::create(class CEGUI::Renderer &,class CEGUI::ResourceProvider *,class CEGUI::XMLParser *,class CEGUI::ImageCodec *,class CEGUI::ScriptModule *,class CEGUI::String const &,class CEGUI::String const &)" (__imp_?create@System@CEGUI@@SAAAV12@AAVRenderer@2@PAVResourceProvider@2@PAVXMLParser@2@PAVImageCodec@2@PAVScriptModule@2@ABVString@2@5@Z) referenced in function "public: __thiscall CGameCanvas::CGameCanvas(class wxWindow *,int,class wxPoint const &,class wxSize const &,long)" (??0CGameCanvas@@QAE@PAVwxWindow@@HABVwxPoint@@ABVwxSize@@J@Z)
CGameCanvas.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: __thiscall CEGUI::String::String(char const *)" (__imp_??0String@CEGUI@@QAE@PBD@Z) referenced in function "public: __thiscall CGameCanvas::CGameCanvas(class wxWindow *,int,class wxPoint const &,class wxSize const &,long)" (??0CGameCanvas@@QAE@PAVwxWindow@@HABVwxPoint@@ABVwxSize@@J@Z)
CGameCanvas.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: static class CEGUI::OpenGLRenderer & __cdecl CEGUI::OpenGLRenderer::create(enum CEGUI::OpenGLRenderer::TextureTargetType)" (__imp_?create@OpenGLRenderer@CEGUI@@SAAAV12@W4TextureTargetType@12@@Z) referenced in function "public: __thiscall CGameCanvas::CGameCanvas(class wxWindow *,int,class wxPoint const &,class wxSize const &,long)" (??0CGameCanvas@@QAE@PAVwxWindow@@HABVwxPoint@@ABVwxSize@@J@Z)
CGameCanvas.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: void __thiscall CEGUI::System::renderGUI(void)" (__imp_?renderGUI@System@CEGUI@@QAEXXZ) referenced in function "private: virtual void __thiscall CGameCanvas::OnUpdate(void)" (?OnUpdate@CGameCanvas@@EAEXXZ)
CGameCanvas.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: static class CEGUI::System & __cdecl CEGUI::System::getSingleton(void)" (__imp_?getSingleton@System@CEGUI@@SAAAV12@XZ) referenced in function "private: virtual void __thiscall CGameCanvas::OnUpdate(void)" (?OnUpdate@CGameCanvas@@EAEXXZ)


when compiling my application with CEGUI static libs (I added these libs in the additional library dependencies):

glu32.lib
pcre.lib
CEGUIBase_Static.lib
CEGUIExpatParser_Static.lib
CEGUISILLYImageCodec_Static.lib
CEGUIOpenGLRenderer_Static.lib
CEGUIFalagardWRBase_Static.lib
expat.lib
SILLY.lib


I can get rid of the errors if I use the DLL version of CEGUIBase and CEGUIOpenGLRenderer:
- CEGUIBase_Static.lib to CEGUIBase.lib
- CEGUIOpenGLRenderer_Static.lib to CEGUIOpenGLRenderer.lib
But I want to minimize the use of DLLs in my application.

I just started using CEGUI by reading the docs and tutorial, and only used 2 objects from CEGUI: CEGUI::System and CEGUI::OpenGLRenderer.
Probably that's why I can get rid of the errors only by switching to DLL version of the 2 libs (Base and OpenGLRenderer), but I'm sure that I will have to use the DLL version of the other libs when I start using them (such as SILLY, ExpatParser, and Falagard)

Please kindly guide me out of this error =) I am new to CEGUI.

Additional information:
- I am using Multi-threaded DLL (/MD) runtime
- The application I am creating is using wxWidgets 2.8.10 in an SFML 1.6 (OpenGL) canvas, both static library.
- Microsoft Visual C++ 2008 Express

Any kind of help would be appreciated :)

Re: Unresolved external symbol when compiling with static libs

Posted: Tue Apr 20, 2010 08:57
by CrazyEddie
The key here is to define CEGUI_STATIC when building your app.

- I am using Multi-threaded DLL (/MD) runtime

Because of this, however, you also need to ensure that CEGUI's static libs are build using the same runtime. This can be done in 0.7.1 and later by setting the STATIC_BUILD_WITH_DYNAMIC_DEPS setting in config.lua to true and rebuilding.

HTH

CE.