Visual Studio
From Seven Kingdoms
Building with Microsoft Visual Studio
There is some experimentation involved with setting up a Visual Studio project file for the Seven Kingdoms source code, but the following steps should get you a long way.
Steps to set up a project file that can build the source code:
- Create a new empty project
- Add all the game files to the project. When there is a choice between different libraries then you should only include the file belonging to the library you want to use (e.g. if you are using sdl include those files and not the ddraw files, and vice versa)
- Ensure you have the Win32 SDK framework (for VC++) installed on your system (needed for writing Win32 code under VC++). Please install the development libraries and headers for SDL, SDL_net, and OpenAl. Alternatively, you could use the DirectX SDK if you are using DirectDraw, DirectInput, etc. DirectX is deprecated, and already has the old DirectPlay module removed.
- In the project configuration properties, set the following (might be slightly different if you are using a different version than Microsoft Visual Studio 2005):
- Under C/C++, General
- - Set Character Set to Use Multi-Byte Character Set
- - Add the path to the "7kaa\include" directory to 'Additional Include Directories'
- - Add path(s) for SDL, SDL_net, or OpenAL
- - If you want to debug, set Debug Information Format to 'Program Database for Edit & Continue' (not tested yet)
- - Set the Warning Level to something appropriate for you. I suggest Level 3
- Under C/C++, Optimization
- - Set Optimization to Disabled
- Under C/C++, Preprocessor
- Add the following preprocessor definitons:
- _DEBUG
- WIN32
- _WINDOWS
- WIN32_LEAN_AND_MEAN
- _CRT_NONSTDC_NO_DEPRECATE
- _CRT_SECURE_NO_DEPRECATE
- DEBUG
- AMPLUS
- NO_ASM
- To use SDL and OpenAL
- USE_SDL
- USE_SDLNET
- USE_OPENAL
- OPENAL_AL_H=<AL/al.h>
- OPENAL_ALC_H=<AL/alc.h>
- If you wish to use DirectX
- USE_DDRAW
- USE_DINPUT
- USE_DSOUND
- USE_NONETPLAY
- _DEBUG and DEBUG are only for the Debug configuration. They should be disabled in the Release configuration
- _CRT_SECURE_NO_DEPRECATE disables a lot of warnings which makes it easier to read the build results
- If you are using SDL then you'll need to set different USE_* macro's (and link to the proper libraries)
- Under C/C++, Code Generation
- - Optionally set Enable Minimal Rebuild to Yes. Set this to No if you are unsure and/or not experienced with incremental builds. With this turned on, you may have to do a full rebuild if a normal Build fails.
- - Optionally set Basic Runtime Checks to Both to help with debugging (in debug build)
- - Runtime Library should be Multi-threaded Debug for the debug configuration
- - Struct Member Alignment. This should be set to 1-byte packing for now. Particularly for multiplayer it is important that all structures are the same size across all platforms (no packing).
- Under Linker, General
- - I have set Enable Incremental Linking to Yes. If you are unfamiliar with this, set it to No.
- Under Linker, Additional Dependencies
- - SDL Libs: SDL.lib SDLmain.lib SDL_net.lib OpenAL32.lib
- - DirectX Libs: dsound.lib dinput.lib winmm.lib
- Under Linker, Debugging
- - For the debug configuration, set Generate Debug Info to Yes
- Under Linker, System
- - Set SubSystem to Windows.
- Under Linker, Advanced
- - Set Target Machine to MachineX86
- Do a full rebuild of the project
- You might have to add stdint.h to your include directory, as it is not automatically included by Visual Studio as an include header. Use a Google search to get a copy of the file. So, if MSVC is complaining about this, then download and add it to your project. (Note, VS2010 is supposed to be C99 compatible now, which would include stdint.h)
- If you run into build or link errors, check if you've added all the appropriate headers (compile errors) and have linked to all the needed libraries (linker errors). You can also check the mailing list to see if anyone has found a similar problem (and solution).
- If you made patches yourself to aid in building, don't forget to share (please follow the patch guidelines outlined on the wiki)
Finally, if you want to debug the application using the IDE debugger, you should really create a file called DEBUG.SYS in the Seven Kingdoms directory. If you don't, the application will be unresponsive when Alt+Tabbing and then trying to activate it (due to locking of the front buffer). (Note: SDL does seem to otherwise act fine windowed)
Please feel free to update this page with any additional information or experience useful to others wanting to try the same.
