• Civilization 7 has been announced. For more info please check the forum here .

Compiling the DLL with the VS2013 Compiler

S3rgeus

Emperor
Joined
Apr 10, 2011
Messages
1,270
Location
London, United Kingdom
Has anyone had any success compiling the DLL with any newer versions of the Visual Studio compiler? I'm not familiar enough with how compiled native binaries interact to say for sure it's possible to do this, since the existing third party libs (FireWorks etc) were built using the older compiler.

So, from a simple "press the button VS gives you" approach, I (strangely) get just one compiler error compiling the BNW DLL with the VS2013 toolchain. The error is an "unable to convert all arguments" in the CvLuaPlayer::lGetTeam function (it can't work out what to do with that call to BasicLuaMethod). I'm not sure why just that one doesn't work, but it's an easy enough fix to change the code to get the team manually like this:

Code:
	auto* pkPlayer = GetInstance(L);
	lua_pushinteger(L, pkPlayer->getTeam());
	return 1;

Then it compiles (with many more warnings than the VS2008 compiler gave me) but I get a bunch of linker errors about unresolved external symbols in FireWorks (and some other dependencies). This is what makes me think it might not be possible to do this in the first place, but thought I'd check to see if anyone else has had any success.

The full text of the linker errors:

Spoiler :
Code:
Error	2	error LNK2001: unresolved external symbol "__declspec(dllimport) void __cdecl std::_Throw(class stdext::exception const &)" (__imp_?_Throw@std@@YAXABVexception@stdext@@@Z)	E:\Documents\Coding\CivMods\DLL\CvGameCoreDLL_Expansion2\CvWorldBuilderMapWin32.lib(CvWorldBuilderMap.obj)	CvGameCoreDLL_Expansion2
Error	3	error LNK2001: unresolved external symbol "__declspec(dllimport) protected: char const * __thiscall std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >::_Myptr(void)const " (__imp_?_Myptr@?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@IBEPBDXZ)	E:\Documents\Coding\CivMods\DLL\CvGameCoreDLL_Expansion2\CvWorldBuilderMapWin32.lib(CvWorldBuilderMap.obj)	CvGameCoreDLL_Expansion2
Error	4	error LNK2001: unresolved external symbol "__declspec(dllimport) public: class std::basic_string<wchar_t,struct std::char_traits<wchar_t>,class std::allocator<wchar_t> > & __thiscall std::basic_string<wchar_t,struct std::char_traits<wchar_t>,class std::allocator<wchar_t> >::operator=(wchar_t const *)" (__imp_??4?$basic_string@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@QAEAAV01@PB_W@Z)	E:\Documents\Coding\CivMods\DLL\CvGameCoreDLL_Expansion2\CvGameCoreDLLUtilWin32.lib(CvStringUtils.obj)	CvGameCoreDLL_Expansion2
Error	5	error LNK2001: unresolved external symbol "__declspec(dllimport) public: unsigned int __thiscall std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >::size(void)const " (__imp_?size@?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QBEIXZ)	E:\Documents\Coding\CivMods\DLL\CvGameCoreDLL_Expansion2\CvGameCoreDLLUtilWin32.lib(CvStringUtils.obj)	CvGameCoreDLL_Expansion2
Error	6	error LNK2001: unresolved external symbol "__declspec(dllimport) public: unsigned int __thiscall std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >::size(void)const " (__imp_?size@?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QBEIXZ)	E:\Documents\Coding\CivMods\DLL\CvGameCoreDLL_Expansion2\FireWorksWin32.lib(FDataStream.obj)	CvGameCoreDLL_Expansion2
Error	7	error LNK2001: unresolved external symbol "__declspec(dllimport) public: __thiscall std::basic_string<wchar_t,struct std::char_traits<wchar_t>,class std::allocator<wchar_t> >::basic_string<wchar_t,struct std::char_traits<wchar_t>,class std::allocator<wchar_t> >(void)" (__imp_??0?$basic_string@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@QAE@XZ)	E:\Documents\Coding\CivMods\DLL\CvGameCoreDLL_Expansion2\CvGameCoreDLLUtilWin32.lib(CvStringUtils.obj)	CvGameCoreDLL_Expansion2
Error	8	error LNK2001: unresolved external symbol "__declspec(dllimport) public: wchar_t const * __thiscall std::basic_string<wchar_t,struct std::char_traits<wchar_t>,class std::allocator<wchar_t> >::c_str(void)const " (__imp_?c_str@?$basic_string@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@QBEPB_WXZ)	E:\Documents\Coding\CivMods\DLL\CvGameCoreDLL_Expansion2\CvGameCoreDLLUtilWin32.lib(CvStringUtils.obj)	CvGameCoreDLL_Expansion2
Error	9	error LNK2001: unresolved external symbol "__declspec(dllimport) public: wchar_t const * __thiscall std::basic_string<wchar_t,struct std::char_traits<wchar_t>,class std::allocator<wchar_t> >::c_str(void)const " (__imp_?c_str@?$basic_string@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@QBEPB_WXZ)	E:\Documents\Coding\CivMods\DLL\CvGameCoreDLL_Expansion2\FireWorksWin32.lib(FDataStream.obj)	CvGameCoreDLL_Expansion2
Error	10	error LNK2001: unresolved external symbol "__declspec(dllimport) public: unsigned int __thiscall std::basic_string<wchar_t,struct std::char_traits<wchar_t>,class std::allocator<wchar_t> >::size(void)const " (__imp_?size@?$basic_string@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@QBEIXZ)	E:\Documents\Coding\CivMods\DLL\CvGameCoreDLL_Expansion2\CvGameCoreDLLUtilWin32.lib(CvStringUtils.obj)	CvGameCoreDLL_Expansion2
Error	11	error LNK2001: unresolved external symbol "__declspec(dllimport) public: unsigned int __thiscall std::basic_string<wchar_t,struct std::char_traits<wchar_t>,class std::allocator<wchar_t> >::size(void)const " (__imp_?size@?$basic_string@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@QBEIXZ)	E:\Documents\Coding\CivMods\DLL\CvGameCoreDLL_Expansion2\FireWorksWin32.lib(FDataStream.obj)	CvGameCoreDLL_Expansion2
Error	12	error LNK2001: unresolved external symbol "__declspec(dllimport) protected: wchar_t const * __thiscall std::basic_string<wchar_t,struct std::char_traits<wchar_t>,class std::allocator<wchar_t> >::_Myptr(void)const " (__imp_?_Myptr@?$basic_string@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@IBEPB_WXZ)	E:\Documents\Coding\CivMods\DLL\CvGameCoreDLL_Expansion2\FireWorksWin32.lib(FDataStream.obj)	CvGameCoreDLL_Expansion2
Error	13	error LNK2001: unresolved external symbol "__declspec(dllimport) public: class std::basic_string<wchar_t,struct std::char_traits<wchar_t>,class std::allocator<wchar_t> > & __thiscall std::basic_string<wchar_t,struct std::char_traits<wchar_t>,class std::allocator<wchar_t> >::assign(wchar_t const *,unsigned int)" (__imp_?assign@?$basic_string@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@QAEAAV12@PB_WI@Z)	E:\Documents\Coding\CivMods\DLL\CvGameCoreDLL_Expansion2\FireWorksWin32.lib(FDataStream.obj)	CvGameCoreDLL_Expansion2
Error	14	error LNK2001: unresolved external symbol "__declspec(dllimport) public: wchar_t const * __thiscall std::basic_string<wchar_t,struct std::char_traits<wchar_t>,class std::allocator<wchar_t> >::data(void)const " (__imp_?data@?$basic_string@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@QBEPB_WXZ)	E:\Documents\Coding\CivMods\DLL\CvGameCoreDLL_Expansion2\FireWorksWin32.lib(FDataStream.obj)	CvGameCoreDLL_Expansion2
Error	15	error LNK2001: unresolved external symbol "__declspec(dllimport) public: void __thiscall std::basic_string<wchar_t,struct std::char_traits<wchar_t>,class std::allocator<wchar_t> >::clear(void)" (__imp_?clear@?$basic_string@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@QAEXXZ)	E:\Documents\Coding\CivMods\DLL\CvGameCoreDLL_Expansion2\FireWorksWin32.lib(FDataStream.obj)	CvGameCoreDLL_Expansion2
Error	16	error LNK2001: unresolved external symbol "__declspec(dllimport) public: char const * __thiscall std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >::data(void)const " (__imp_?data@?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QBEPBDXZ)	E:\Documents\Coding\CivMods\DLL\CvGameCoreDLL_Expansion2\FireWorksWin32.lib(FDataStream.obj)	CvGameCoreDLL_Expansion2
Error	17	error LNK2001: unresolved external symbol "__declspec(dllimport) public: void __thiscall std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >::clear(void)" (__imp_?clear@?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAEXXZ)	E:\Documents\Coding\CivMods\DLL\CvGameCoreDLL_Expansion2\FireWorksWin32.lib(FDataStream.obj)	CvGameCoreDLL_Expansion2
Error	18	error LNK2001: unresolved external symbol "__declspec(dllimport) bool __cdecl std::operator==<char,struct std::char_traits<char>,class std::allocator<char> >(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &)" (__imp_??$?8DU?$char_traits@D@std@@V?$allocator@D@1@@std@@YA_NABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@0@0@Z)	E:\Documents\Coding\CivMods\DLL\CvGameCoreDLL_Expansion2\FireWorksWin32.lib(FAutoArchive.obj)	CvGameCoreDLL_Expansion2
Error	19	error LNK2001: unresolved external symbol "__declspec(dllimport) public: void __thiscall std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >::push_back(char)" (__imp_?push_back@?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAEXD@Z)	E:\Documents\Coding\CivMods\DLL\CvGameCoreDLL_Expansion2\FireWorksWin32.lib(FStlContainerSerialization.obj)	CvGameCoreDLL_Expansion2
Error	20	error LNK2001: unresolved external symbol "__declspec(dllimport) public: class std::_String_const_iterator<char,struct std::char_traits<char>,class std::allocator<char> > __thiscall std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >::end(void)const " (__imp_?end@?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QBE?AV?$_String_const_iterator@DU?$char_traits@D@std@@V?$allocator@D@2@@2@XZ)	E:\Documents\Coding\CivMods\DLL\CvGameCoreDLL_Expansion2\FireWorksWin32.lib(FStlContainerSerialization.obj)	CvGameCoreDLL_Expansion2
Error	21	error LNK2001: unresolved external symbol "__declspec(dllimport) public: class std::_String_const_iterator<char,struct std::char_traits<char>,class std::allocator<char> > __thiscall std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >::begin(void)const " (__imp_?begin@?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QBE?AV?$_String_const_iterator@DU?$char_traits@D@std@@V?$allocator@D@2@@2@XZ)	E:\Documents\Coding\CivMods\DLL\CvGameCoreDLL_Expansion2\FireWorksWin32.lib(FStlContainerSerialization.obj)	CvGameCoreDLL_Expansion2
Error	22	error LNK1120: 17 unresolved externals	E:\Documents\Coding\CivMods\DLL\\BuildOutput\VS2013_ModDebugWin32\\CvGameCore_Expansion2.dll	CvGameCoreDLL_Expansion2
 
Well FWIW I tried it a couple of months ago and got pretty much the same result. At that point I went and got the old version.

:dunno:
 
If you work out how, please update the "How to compile the DLL" stickied thread, as I'd like to know as well!

I'm thinking that these linker errors are due to differences in the VC++ runtime libs between 2008 and 2013 (cropping up where Fireworks and co. use some function that is no longer defined). If that is the case, it doesn't look like there's much we can do without the source for FireWorks and WorldBuilder and possibly some other parts of CiV. :(

I haven't had any trouble using VS2013 with the 2008 compiler like you've described in that post though. I just get this:



And it compiles like it did in VS2010. (Annoyingly I only have the express version of 2008, so I'm missing out on shiny VS2013 features :( ) VS2013's Intellisense is much better at coping with the CiV source code though - F12 is instant about 90% of the time, up from 0.2%, which is really nice. Syntax highlighting works correctly in most files fairly quickly too.
 
I am trying to do the same as the OP and am facing the same compiler errors. I'm assuming they are inherent compatibility issues as i'm also using VS 2013. Oddly enough the folder with the source code has a CvGameCoreDLL.vs2013.sln so you would assume it's compitiable.

You can absolutely compile the DLL with VS 2013. You just need the VS 2008 toolchain installed so that the project can use it.
How do you do that? A quick google search took me here, in which none of the links took me to a viable download:

https://www.wireshark.org/docs/wsdg_html_chunked/ChToolsMSChain.html

So in short I was unable to figure out how to download and install VS 2008 toolchain for VS 2013.

EDIT: made mistake in my final sentence. I was referring to VS 2008 toolchain not VS 2008.
 
If you install VS2008 then that toolchain will become available for use by VS2013. If you've "upgraded" your project to a VS2013 project (which Visual Studio asks you to do) then you'll need to undo that (paste over it with a copy from the CiV SDK directory) - the CiV libs we don't have source for (FireWorks, WorldBuilder) were compiled against different versions of the standard libraries from what VS2013 uses, so you can't link against them with the VS2013 toolchain.

If you trust a random link from a good samaritan, you can download VS2008 express here. Or just Google "Visual Studio 2008 Express" and the official Microsoft download should be the first result.
 
If you install VS2008 then that toolchain will become available for use by VS2013. If you've "upgraded" your project to a VS2013 project (which Visual Studio asks you to do) then you'll need to undo that (paste over it with a copy from the CiV SDK directory) - the CiV libs we don't have source for (FireWorks, WorldBuilder) were compiled against different versions of the standard libraries from what VS2013 uses, so you can't link against them with the VS2013 toolchain.

If you trust a random link from a good samaritan, you can download VS2008 express here. Or just Google "Visual Studio 2008 Express" and the official Microsoft download should be the first result.
Thank you for the feedback.

If you've "upgraded" your project to a VS2013 project (which Visual Studio asks you to do) then you'll need to undo that (paste over it with a copy from the CiV SDK directory)
Unfortunately doing so prevents me from being able to open the projects / solution in Visual Studio 2013. I had no choice but to accept to convert it over. I tried to restrict the conversion to the sln only and not the project files, but upon opening the solution I was forced to convert the project files as well. This resulted in the same compilation errors upon build.

Note: I opened the 2008 solution file in vs 2013. I will try the 2013 and update this post accordingly.
 
Update:

Following my aforementioned attempt to open the visual studio 2013 solution, after having installed vs 2008, I encountered the following error:

error MSB8020: The builds tools for Visual Studio 2008 (Platform Toolset = 'v90') cannot be found. To build using the v90 build tools,
either click the Project menu or right-click the solution, and then select "Update VC++ Projects...". Install Visual Studio 2008 to build
using the Visual Studio 2008 build tools.

I did some research on the aforementioned error and it turned out that both vs 2008 and vs 2010 express need to be installed. Installing vs 2010 effectively solved my problem and I can now compile in vs2013.

My only current gripe is that the function references (text above functions that indicate where and how many times the function is being called from) that VS 2013 ultimate is known for is not showing up. It was for this reason in itself that I was trying to get it to work in VS 2013 in the first place. I checked my installation options of VS 2013, and I don't have MFC for C++ installed but I don't see that as relevant to this issue.

Would be good to know if anyone got the references to show up in VS 2013 :)
 
Update:

Following my aforementioned attempt to open the visual studio 2013 solution, after having installed vs 2008, I encountered the following error:

error MSB8020: The builds tools for Visual Studio 2008 (Platform Toolset = 'v90') cannot be found. To build using the v90 build tools,
either click the Project menu or right-click the solution, and then select "Update VC++ Projects...". Install Visual Studio 2008 to build
using the Visual Studio 2008 build tools.

I did some research on the aforementioned error and it turned out that both vs 2008 and vs 2010 express need to be installed. Installing vs 2010 effectively solved my problem and I can now compile in vs2013.

My only current gripe is that the function references (text above functions that indicate where and how many times the function is being called from) that VS 2013 ultimate is known for is not showing up. It was for this reason in itself that I was trying to get it to work in VS 2013 in the first place. I checked my installation options of VS 2013, and I don't have MFC for C++ installed but I don't see that as relevant to this issue.

Would be good to know if anyone got the references to show up in VS 2013 :)

Awesome, glad you have it working. I already had VS2010, but I didn't know it was actually a dependency of being able to get everything up and running.

I was under the impression that CodeLens (which is what does the referenced by, tested by, and VCS changes marking in VS2013) was only available in VB and C#, not in C++.
 
Awesome, glad you have it working. I already had VS2010, but I didn't know it was actually a dependency of being able to get everything up and running.

I was under the impression that CodeLens (which is what does the referenced by, tested by, and VCS changes marking in VS2013) was only available in VB and C#, not in C++.
A quick search indicated that this is the case. C# and VB supports CodeLens but not C++. Thats too bad, as CodeLens is hugely beneficial, particularly when trying to learn the overall structure of new code. That being said, I just verified that one can still select a function and press Shift+F12 - this brings up all the places the function is being called from.
 
Top Bottom