I am trying to compile my code into a single DLL (or at least the CEGUI code) so that when I inject it into another process, there aren't loads of dependency DLLs that have to be in the process's directory.
However, I am having some problems getting the DLL to build with the config I have, and maybe I am not understanding something. I have read quite a few threads on the forum about static linking, but all of the ones I have seen seem to have had different solutions (that either don't relate to the problem's I'm having, or have solutions that I have already tried/impelemented in an attempt to get this working).
I already have #define CEGUI_STATIC in my code. I also added CEGUI_STATIC to the Preprocessor Definitions. I have also changed the Runtime Library to use /MT. My Configuration Type is obviously still on "Dynamic Library". I changed all my libraries defined in the Additional Dependencies list to the _Static variants (e.g. changed CEGUIBase.lib to CEGUIBase_Static.lib, but now I am getting a load of unresolved external symbols when trying to build. I also tried changing STATIC_BUILD_WITH_DYNAMIC_DEPS to both true and false in config.lua and rebuiliding and this didn't seem to matter.
So I tried to start again...
-- I have edited Config.lua to add the DirectX SDK directories to CEGUI_EXTRA_PATHS and set STATIC_BUILD_WITH_DYNAMIC_DEPS to false.
-- Then I re-ran the build_cs2008.bat.
-- Then opened the resulting CEGUI.sln in VC++2010 and converted from the 2008 version to 2010.
-- Then I selected the Release_Static build version and rebuild the entire solution.
-- I then removed everything from all of the "VC++ Directories" lists.
-- I then added just the "cegui\include", "cegui\include\RendererModules\Direct3D9" and "DirectXSDK\Include" directories into the "Additional Include Directories" list.
-- I added the Microsoft SDK Lib directory to the "Additional Library Directories" list
-- I made sure "CEGUI_STATIC" was in the Preprocessor Definitions.
-- I added all of the static versions of the files into the "Additional Dependencies" list by full path to make sure I was using the static versions. These are what I have:
C:\Utilities\CEGUI-SDK-0.7.5-vc10\lib\CEGUIBase_Static.lib
C:\Utilities\CEGUI-SDK-0.7.5-vc10\lib\CEGUIDirect3D9Renderer_Static.lib
C:\Utilities\CEGUI-SDK-0.7.5-vc10\lib\CEGUIFalagardWRBase_Static.lib
C:\Utilities\CEGUI-SDK-0.7.5-vc10\lib\CEGUIExpatParser_Static.lib
C:\Utilities\CEGUI-SDK-0.7.5-vc10\lib\CEGUISILLYImageCodec_Static.lib
C:\Utilities\CEGUI-SDK-0.7.5-vc10\dependencies\lib\static\pcre.lib
C:\Utilities\CEGUI-SDK-0.7.5-vc10\dependencies\lib\static\expat.lib
C:\Utilities\CEGUI-SDK-0.7.5-vc10\dependencies\lib\static\SILLY.lib
I still had a load of unresolved external sybmol errors, so I changed SILLY.lib in the list above to use the one in the /dynamic directory and this seemed to get rid of those problems (not sure if it was the correct thing to do), but I am still having some others, seemingly to do with CEGUIBase. I am not sure what else I have to do to get this statically linking all the CEGUI code, but I still have the following unresolved external errors:
Code: Select all
1> Creating library C:\Users\smokedog\Desktop\DirectX\Direct3D-Hook\Release\Direct3D-Hook.lib and object C:\Users\smokedog\Desktop\DirectX\Direct3D-Hook\Release\Direct3D-Hook.exp
1>Direct3D-Hook.obj : error LNK2019: unresolved external symbol __imp__PathStripPathA@4 referenced in function _DllMain@12
1>CEGUIBase_Static.lib(CEGUISystem.obj) : error LNK2019: unresolved external symbol __imp__timeGetTime@0 referenced in function "public: static double __cdecl CEGUI::SimpleTimer::currentTime(void)" (?currentTime@SimpleTimer@CEGUI@@SANXZ)
1>CEGUIBase_Static.lib(CEGUIFreeTypeFont.obj) : error LNK2019: unresolved external symbol _FT_Load_Char referenced in function "protected: unsigned int __thiscall CEGUI::FreeTypeFont::getTextureSize(class std::_Tree_const_iterator<class std::_Tree_val<class std::_Tmap_traits<unsigned int,class CEGUI::FontGlyph,struct std::less<unsigned int>,class std::allocator<struct std::pair<unsigned int const ,class CEGUI::FontGlyph> >,0> > >,class std::_Tree_const_iterator<class std::_Tree_val<class std::_Tmap_traits<unsigned int,class CEGUI::FontGlyph,struct std::less<unsigned int>,class std::allocator<struct std::pair<unsigned int const ,class CEGUI::FontGlyph> >,0> > >)const " (?getTextureSize@FreeTypeFont@CEGUI@@IBEIV?$_Tree_const_iterator@V?$_Tree_val@V?$_Tmap_traits@IVFontGlyph@CEGUI@@U?$less@I@std@@V?$allocator@U?$pair@$$CBIVFontGlyph@CEGUI@@@std@@@4@$0A@@std@@@std@@@std@@0@Z)
1>CEGUIBase_Static.lib(CEGUIFreeTypeFont.obj) : error LNK2019: unresolved external symbol _FT_Done_Face referenced in function "protected: void __thiscall CEGUI::FreeTypeFont::free(void)" (?free@FreeTypeFont@CEGUI@@IAEXXZ)
1>CEGUIBase_Static.lib(CEGUIFreeTypeFont.obj) : error LNK2019: unresolved external symbol _FT_Get_Next_Char referenced in function "protected: virtual void __thiscall CEGUI::FreeTypeFont::updateFont(void)" (?updateFont@FreeTypeFont@CEGUI@@MAEXXZ)
1>CEGUIBase_Static.lib(CEGUIFreeTypeFont.obj) : error LNK2019: unresolved external symbol _FT_Get_First_Char referenced in function "protected: virtual void __thiscall CEGUI::FreeTypeFont::updateFont(void)" (?updateFont@FreeTypeFont@CEGUI@@MAEXXZ)
1>CEGUIBase_Static.lib(CEGUIFreeTypeFont.obj) : error LNK2019: unresolved external symbol _FT_Set_Char_Size referenced in function "protected: virtual void __thiscall CEGUI::FreeTypeFont::updateFont(void)" (?updateFont@FreeTypeFont@CEGUI@@MAEXXZ)
1>CEGUIBase_Static.lib(CEGUIFreeTypeFont.obj) : error LNK2019: unresolved external symbol _FT_New_Memory_Face referenced in function "protected: virtual void __thiscall CEGUI::FreeTypeFont::updateFont(void)" (?updateFont@FreeTypeFont@CEGUI@@MAEXXZ)
1>CEGUIBase_Static.lib(CEGUIFreeTypeFont.obj) : error LNK2019: unresolved external symbol _FT_Init_FreeType referenced in function "public: __thiscall CEGUI::FreeTypeFont::FreeTypeFont(class CEGUI::String const &,float,bool,class CEGUI::String const &,class CEGUI::String const &,bool,float,float,float)" (??0FreeTypeFont@CEGUI@@QAE@ABVString@1@M_N001MMM@Z)
1>CEGUIBase_Static.lib(CEGUIFreeTypeFont.obj) : error LNK2019: unresolved external symbol _FT_Done_FreeType referenced in function "public: virtual __thiscall CEGUI::FreeTypeFont::~FreeTypeFont(void)" (??1FreeTypeFont@CEGUI@@UAE@XZ)
1>C:\Users\smokedog\Desktop\DirectX\Direct3D-Hook\Release\Direct3D-Hook.dll : fatal error LNK1120: 10 unresolved externals
Here is my compiler command line:
Code: Select all
/I"C:\Utilities\CEGUI-SDK-0.7.5-vc10\cegui\include\RendererModules\Direct3D9" /I"C:\Utilities\Microsoft DirectX SDK (June 2010)\Include" /I"C:\Utilities\CEGUI-SDK-0.7.5-vc10\cegui\include" /Zi /nologo /W3 /WX- /O2 /Oy- /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_USRDLL" /D "DIRECT3DHOOK_EXPORTS" /D "_CRT_SECURE_NO_DEPRECATE" /D "CEGUI_STATIC" /D "_WINDLL" /D "_MBCS" /Gm- /EHsc /MT /GS /fp:precise /Zc:wchar_t /Zc:forScope /Fp"Release\Direct3D-Hook.pch" /Fa"Release\" /Fo"Release\" /Fd"Release\vc100.pdb" /Gd /analyze- /errorReport:queue
and here is my linker command line:
Code: Select all
/OUT:"C:\Projects\Direct3D-Hook\Release\Direct3D-Hook.dll" /NOLOGO /LIBPATH:"C:\Utilities\CEGUI-SDK-0.7.5-vc10\lib" /LIBPATH:"C:\Utilities\CEGUI-SDK-0.7.5-vc10\lib\ReleaseWithSymbols" /LIBPATH:"C:\Utilities\CEGUI-SDK-0.7.5-vc10\dependencies\lib\static" /LIBPATH:"C:\Utilities\CEGUI-SDK-0.7.5-vc10\dependencies\lib\dynamic" /LIBPATH:"C:\Utilities\Microsoft DirectX SDK (June 2010)\Lib\x86" /DLL "C:\Utilities\CEGUI-SDK-0.7.5-vc10\lib\CEGUIBase_Static.lib" "C:\Utilities\CEGUI-SDK-0.7.5-vc10\lib\CEGUIDirect3D9Renderer_Static.lib" "C:\Utilities\CEGUI-SDK-0.7.5-vc10\lib\CEGUIFalagardWRBase_Static.lib" "C:\Utilities\CEGUI-SDK-0.7.5-vc10\lib\CEGUIExpatParser_Static.lib" "C:\Utilities\CEGUI-SDK-0.7.5-vc10\lib\CEGUISILLYImageCodec_Static.lib" "C:\Utilities\CEGUI-SDK-0.7.5-vc10\dependencies\lib\static\pcre.lib" "C:\Utilities\CEGUI-SDK-0.7.5-vc10\dependencies\lib\static\expat.lib" "C:\Utilities\CEGUI-SDK-0.7.5-vc10\dependencies\lib\dynamic\SILLY.lib" "kernel32.lib" "user32.lib" "gdi32.lib" "winspool.lib" "comdlg32.lib" "advapi32.lib" "shell32.lib" "ole32.lib" "oleaut32.lib" "uuid.lib" "odbc32.lib" "odbccp32.lib" /MANIFEST /ManifestFile:"Release\Direct3D-Hook.dll.intermediate.manifest" /ALLOWISOLATION /MANIFESTUAC:"level='asInvoker' uiAccess='false'" /PDB:"C:\Projects\Direct3D-Hook\Release\Direct3D-Hook.pdb" /SUBSYSTEM:WINDOWS /OPT:REF /OPT:ICF /PGD:"C:\Projects\Direct3D-Hook\Release\Direct3D-Hook.pgd" /TLBID:1 /DYNAMICBASE /NXCOMPAT /MACHINE:X86 /ERRORREPORT:QUEUE
[Edit:] I just tried chainging STATIC_BUILD_WITH_DYNAMIC_DEPS back to true, rebuilding the CEGUI solution in Release mode, and changing my dependencies in my project to use the Dynamic subdirectories, and changing my Runtime to MT and MD, and although my project builds with either of these Runtimes, my game still complains about missing CEGUIBase.dll as soon as it is injected.