[BTS] The Easiest Way to Compile a New DLL

Delete this file and clean the build. After that try again. It looks like you have the .res file compiled against the 7.0A SDK.
No, it failed much earlier now:
Code:
1>------ Build started: Project: A New Dawn, Configuration: Final_Release Win32 ------
1> 
1>  Microsoft (R) Program Maintenance Utility Version 10.00.30319.01
1>  Copyright (C) Microsoft Corporation.  All rights reserved.
1> 
1>  SubWCRev: 'J:\INSTALL_GAMES\Civ\_My mod\   AND2 SVN\Sources'
1>  Last committed at revision 1091
1>  Updated to revision 1091
1>  Local modifications found
1>      "C:\Program Files (x86)\Microsoft SDKs\Windows\v6.0\bin\rc.exe" /FoFinal_Release\CvGameCoreDLL.res /IBoost-1.32.0/include /IPython24/include /I"C:\Program Files (x86)\Civ4SDK\Microsoft Visual C++ Toolkit 2003/include" /I"C:\Program Files (x86)\Microsoft SDKs\Windows\v6.0/Include" /I"C:\Program Files (x86)\Microsoft SDKs\Windows\v6.0/Include/mfc" /I"D:\Games\Civilization 4\Beyond the Sword\CvGameCoreDLL\Boost-1.32.0/include" /I"D:\Games\Civilization 4\Beyond the Sword\CvGameCoreDLL\Python24/include" CvGameCoreDLL.rc
1>  Microsoft (R) Windows (R) Resource Compiler Version 6.0.5724.0
1> 
1>  Copyright (C) Microsoft Corporation.  All rights reserved.
1> 
1> 
1>      "C:\Program Files (x86)\Civ4SDK\Microsoft Visual C++ Toolkit 2003\bin\link.exe" /out:Final_Release\CvGameCoreDLL.dll /INCREMENTAL:NO /DEBUG /OPT:REF /OPT:ICF /IMPLIB:"Final_Release\CvGameCoreDLL.def" /PDB:"Final_Release\CvGameCoreDLL.pdb" /DLL /NOLOGO /SUBSYSTEM:WINDOWS /LARGEADDRESSAWARE /TLBID:1 /DEF:CvGameCoreDLL.def /LIBPATH:"D:\Games\Civilization 4\Beyond the Sword\CvGameCoreDLL\Python24/libs" /LIBPATH:"D:\Games\Civilization 4\Beyond the Sword\CvGameCoreDLL\Boost-1.32.0/libs/" boost_python-vc71-mt-1_32.lib thread.obj exceptions.obj condition.obj xtime.obj mutex.obj once.obj recursive_mutex.obj read_write_mutex.obj tss_hooks.obj /LIBPATH:"C:\Program Files (x86)\Civ4SDK\Microsoft Visual C++ Toolkit 2003/lib" /LIBPATH:"C:\Program Files (x86)\Microsoft SDKs\Windows\v6.0/Lib" winmm.lib user32.lib psapi.lib Final_Release\BetterBTSAI.obj  Final_Release\BoolExpr.obj  Final_Release\ByteBuffer.obj  Final_Release\CvAllocator.obj  Final_Release\CvArea.obj  Final_Release\CvArtFileMgr.obj  Final_Release\CvBugOptions.obj  Final_Release\CvBuildingFilters.obj  Final_Release\CvBuildingGrouping.obj  Final_Release\CvBuildingInfo.obj  Final_Release\CvBuildingList.obj  Final_Release\CvBuildingSort.obj  Final_Release\CvBuildLists.obj  Final_Release\CvCity.obj  Final_Release\CvCityAI.obj  Final_Release\CvContractBroker.obj  Final_Release\CvDate.obj  Final_Release\CvDeal.obj  Final_Release\CvDiploParameters.obj  Final_Release\CvDLLButtonPopup.obj  Final_Release\CvDLLEntity.obj  Final_Release\CvDLLPython.obj  Final_Release\CvDllPythonEvents.obj  Final_Release\CvDllTranslator.obj  Final_Release\CvDLLWidgetData.obj  Final_Release\CvDLLXMLRapid.obj  Final_Release\CvEventReporter.obj  Final_Release\CvFractal.obj  Final_Release\CvGame.obj  Final_Release\CvGameAI.obj  Final_Release\CvGameCoreDLL.obj  Final_Release\CvGameCoreUtils.obj  Final_Release\CvGameInterface.obj  Final_Release\CvGameObject.obj  Final_Release\CvGameTextMgr.obj  Final_Release\CvGlobals.obj  Final_Release\CvHallOfFameInfo.obj  Final_Release\CvInfos.obj  Final_Release\CvInfoWater.obj  Final_Release\CvInitCore.obj  Final_Release\CvMap.obj  Final_Release\CvMapExternal.obj  Final_Release\CvMapGenerator.obj  Final_Release\CvMapInterfaceBase.obj  Final_Release\CvMessageControl.obj  Final_Release\CvMessageData.obj  Final_Release\CvOutcome.obj  Final_Release\CvOutcomeList.obj  Final_Release\CvOutcomemission.obj  Final_Release\CvPathGenerator.obj  Final_Release\CvPipeline.obj  Final_Release\CvPlayer.obj  Final_Release\CvPlayerAI.obj  Final_Release\CvPlot.obj  Final_Release\CvPlotGroup.obj  Final_Release\CvPopupInfo.obj  Final_Release\CvPopupReturn.obj  Final_Release\CvProperties.obj  Final_Release\CvPropertyInteraction.obj  Final_Release\CvPropertyManipulators.obj  Final_Release\CvPropertyPropagator.obj  Final_Release\CvPropertySolver.obj  Final_Release\CvPropertySource.obj  Final_Release\CvRandom.obj  Final_Release\CvReachablePlotSet.obj  Final_Release\CvReplayInfo.obj  Final_Release\CvReplayMessage.obj  Final_Release\CvSelectionGroup.obj  Final_Release\CvSelectionGroupAI.obj  Final_Release\CvStatistics.obj  Final_Release\CvStructs.obj  Final_Release\CvTaggedSaveFormatWrapper.obj  Final_Release\CvTalkingHeadMessage.obj  Final_Release\CvTeam.obj  Final_Release\CvTeamAI.obj  Final_Release\CvTextScreens.obj  Final_Release\CvUnit.obj  Final_Release\CvUnitAI.obj  Final_Release\CvUnitFilters.obj  Final_Release\CvUnitGrouping.obj  Final_Release\CvUnitInfo.obj  Final_Release\CvUnitList.obj  Final_Release\CvUnitSort.obj  Final_Release\CvViewport.obj  Final_Release\CvXMLLoadUtility.obj  Final_Release\CvXMLLoadUtilityGet.obj  Final_Release\CvXMLLoadUtilityInit.obj  Final_Release\CvXMLLoadUtilityModTools.obj  Final_Release\CvXMLLoadUtilitySet.obj  Final_Release\CvXMLLoadUtilitySetMod.obj  Final_Release\CyArea.obj  Final_Release\CyAreaInterface.obj  Final_Release\CyArgsList.obj  Final_Release\CyArtFileMgr.obj  Final_Release\CyArtFileMgrInterface.obj  Final_Release\CyCity.obj  Final_Release\CyCityInterface1.obj  Final_Release\CyCityInterface2.obj  Final_Release\CyDeal.obj  Final_Release\CyEnumsInterface.obj  Final_Release\CyGame.obj  Final_Release\CyGameCoreUtils.obj  Final_Release\CyGameCoreUtilsInterface.obj  Final_Release\CyGameInterface.obj  Final_Release\CyGameTextMgr.obj  Final_Release\CyGameTextMgrInterface.obj  Final_Release\CyGlobalContext.obj  Final_Release\CyGlobalContextInterface1.obj  Final_Release\CyGlobalContextInterface2.obj  Final_Release\CyGlobalContextInterface3.obj  Final_Release\CyGlobalContextInterface4.obj  Final_Release\CyHallOfFameInfo.obj  Final_Release\CyHallOfFameInterface.obj  Final_Release\CyInfoInterface1.obj  Final_Release\CyInfoInterface2.obj  Final_Release\CyInfoInterface3.obj  Final_Release\CyInfoInterface4.obj  Final_Release\CyMap.obj  Final_Release\CyMapGenerator.obj  Final_Release\CyMapGeneratorInterface.obj  Final_Release\CyMapInterface.obj  Final_Release\CyMessageControl.obj  Final_Release\CyMessageControlInterface.obj  Final_Release\CyPlayer.obj  Final_Release\CyPlayerInterface1.obj  Final_Release\CyPlayerInterface2.obj  Final_Release\CyPlot.obj  Final_Release\CyPlotInterface1.obj  Final_Release\CyPropertiesInterface.obj  Final_Release\CyRandomInterface.obj  Final_Release\CyReplayInfo.obj  Final_Release\CySelectionGroup.obj  Final_Release\CySelectionGroupInterface.obj  Final_Release\CyStructsInterface1.obj  Final_Release\CyTeam.obj  Final_Release\CyTeamInterface.obj  Final_Release\CyUnit.obj  Final_Release\CyUnitInterface1.obj  Final_Release\FAssert.obj  Final_Release\FDataIOStream.obj  Final_Release\FDataStreamBuffer.obj  Final_Release\FDialogTemplate.obj  Final_Release\FLinedDataIOStream.obj  Final_Release\IntExpr.obj  Final_Release\UTF8Support.obj  Final_Release\_precompile.obj   Final_Release\CvGameCoreDLL.res
1>Final_Release\CvGameCoreDLL.res : fatal error LNK1123: failure during conversion to COFF: file invalid or corrupt
1>LINK : fatal error LNK1141: failure during build of exports file
1>NMAKE : fatal error U1077: '"C:\Program Files (x86)\Civ4SDK\Microsoft Visual C++ Toolkit 2003\bin\link.exe"' : return code '0x475'
1>  Stop.
1>C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\Microsoft.MakeFile.Targets(38,5): error MSB3073: The command "nmake Final_Release" exited with code 2.
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
But I did change to v6.0 already.
 
If you came here from Google, look elsewhere. This guide doesn't work.

The DLL will compile successfully with no errors, but when you try to actually load the mod it will just fail with "DLL Attaching" and "Assert Failed" errors.
 
If you came here from Google, look elsewhere. This guide doesn't work.

The DLL will compile successfully with no errors, but when you try to actually load the mod it will just fail with "DLL Attaching" and "Assert Failed" errors.

The assert failed errors shouldn't crash anything, they're just there to inform you that something went wrong and a value wasn't in the expected range in the DLL's code. You can build a release DLL (instead of a debug one), which won't fix the bugs but will hide them (by not compiling assertions into the DLL).
 
If you came here from Google, look elsewhere. This guide doesn't work.

The DLL will compile successfully with no errors, but when you try to actually load the mod it will just fail with "DLL Attaching" and "Assert Failed" errors.
Ohhhh! I thought those where errors and I compiled the DLL wrong, lol
 
The DLL will compile successfully with no errors, but when you try to actually load the mod it will just fail with "DLL Attaching" and "Assert Failed" errors.
The DLL Attaching assert failure is intentional and will happen every single time with some mods. It is for modders when they want to attach a debugger to the mod while it starts up. It's safe to ignore.

Alternatively you can set up MSVC to start the mod with the debugger attached. That's the approach I use, but it seems only a few modders is aware of this option. It's my impression that most modders don't use debuggers anyway.
 
The DLL Attaching assert failure is intentional and will happen every single time with some mods. It is for modders when they want to attach a debugger to the mod while it starts up. It's safe to ignore.

Alternatively you can set up MSVC to start the mod with the debugger attached. That's the approach I use, but it seems only a few modders is aware of this option. It's my impression that most modders don't use debuggers anyway.
I always use it for debugging. Makes it insanely easier.
 
A quick question; is it necessary to use the 2010 version of Visual Studio? I'm using the 2019 version and it's throwing a load of errors, and I'd like to know if that's because of my Visual Studio version or just me doing something wrong.
 
I am using the 2019 IDE myself to actually edit the code. But you need to have VS 2010 installed.
 
Okay, I managed to compile it with VS 2010, but now whenever I start I get this warning message:

upload_2021-2-18_21-20-27.png


Even clicking 'Ignore Always' doesn't get rid of it. How do I stop it from throwing up these popups all the time? I'm not messing with solar system stuff, and this error has only started popping up ever since I compiled the DLL myself, so am I right in assuming there's something in there I need to change to get rid of this?
 
How do I stop it from throwing up these popups all the time? I'm not messing with solar system stuff, and this error has only started popping up ever since I compiled the DLL myself, so am I right in assuming there's something in there I need to change to get rid of this?

You need to compile "Release" version instead of "Debug" version. You can pick the version in VS, there should be a drop-down menu for that.
 
This is freakin amazing! I tried to follow a mix of outdated threads/make files, but this just works! Once it was set up, it only took my like 15m to make my first code change and test it out. Thanks a ton Leoreth!!
 
Great! Love to hear that it still helps people.
 
Definitely not mine. This is probably very useful for people who prefer to include BULL in their mods, which is probably preferable to the clean base game. My goal here was just to preserve the actual source code in working order, so this can perfectly coexist in my opinion.
 
Okay, I decided to give it another try but I'm stuck very early :sad:
4) Launch your project in Visual Studio

Double click on the CvGameCoreDLL.sln file, it should open in Visual Studio with an already configured project.

The program is not opening any .sln files. Not with double-clicking nor drag'n'drop nor CTRL+O works.
upload_2022-6-23_13-45-19.png

What am I doing wrong?? :confused:
 
Top Bottom