It is possible to use Visual Studio with the Freeciv codebase to build and test revisions to the GTK client.


  • Install a build setup conforming to the instructions for installing MinGw and MySys on the Install-Windows page. This does not require Cygwin.
  • Install Visual studio 2010 trial. I used professional from this location. According to some notes I have seen on developer sites, MS never expires the trial. Don't know if that is true.
  • Install WinGDB. Some notes to orient you to a MinGw setup may be found here. Ignore the details regarding Cygwin. If you are not familiar with the Cygwin environment, this information concerns a separate setup that we aren't using.
  • Config using automake- and build using Mysys command line.
./ --enable-client=gtk-2.0 --with-libiconv-prefix=/usr --host=mingw32
  • make CFLAGS='-DDEBUG -g'
  • For 2.3, copy newly built exe over the client and server exes to a test directory where you have installed the distributed 2.3 release of freeciv.
    • Alternately, you can keep the exe where it is. You must set the Launch Process.Debug.Working directory to test directory root (K:\FreeCiv01 in this example).
  • Visual Studio debug session
  • (examples assume Freeciv2_3 source tree is at C:\MinGW\msys\1.0\home\freeciv2_3 and the test directory is at K:\FreeCiv01)
  • no need to create a new project. Do the following.
  • VSTudio menu WinGDB.Launch Process.General.Target type = Windows Native (MinGW/Cygwin)
  • menu WinGDB.Launch Process.Environment.Debugger Path= C:\MinGW\bin\gdb.exe
  • menu WinGDB.Launch Process.Environment.Build Toolchain Paths= C:\MinGW\bin;c:\bin;c:\Python25;C:\MinGW\msys\1.0\bin
  • optionally postpend other tool directories from your Path to the end of the above path, especially if you have placed gnu tools in different places.
  • menu WinGDB.Launch Process.Environment.Debug.Executable Path=K:\FreeCiv01\freeciv-gtk2.exe
  • menu WinGDB.Launch Process.Environment.Debug.Arguments --log client.log --debug 2
    • debug log output in this setup will therefore be sent to the test directory (Debug.Working directory). In this example, K:\FreeCiv01\client.log
  • menu WinGDB.Launch Process.Environment.Debug.Stop in Main()= Yes
  • menu WinGDB.Launch Process.Environment.Directories.Additional Source Directories= C:\MinGW\msys\1.0\home\freeciv2_3\client; (and so on for server, common, utilities directories...)
  • after pressing OK, you should see gui_main.c on your screen, with a yellow arrow at the main() function's first statement
return client_main(argc, argv);
  • For server, set up a separate instance of Studio 2010, with corresponding settings for server, outputting to server.log
  • After you have the server cli interface up, type "load testfile" where testfile is an example testfile (no extension) saved from a normal working version of Freeciv.
  • From the Client instance, you may use Studio's standard functions to watch values, set breakpoints, do macros and so on. eg:
  • Press F11 to step into the first statement. (or menu Debug.Step Into)
  • Highlight argv and Debug.Add Watch. Click argv to expand and you will see the path of the exe.
  • Press F5 (menu Debug.Continue)... You should see the Freeciv initial splash screen appear.
  • Click the start screen option "Connect to Network server", and select the server instance you just loaded.
  • Menu Debug.Break All
  • Click Call Stack tab at bottom. You are idling in GTK's dll. Click the non greyed lines for your source. Everything in your modules should be non greyed. If not, add more directories to the "Additional Source Directories" item above.
  • for example, you should see a stack item > freeciv-gtk2.exe!ui_main( 1, 0x11339e0 ) Line 1669 (line # may be slightly different). You should see a green pointer next to line gtk_main();
  • Save these debug settings. menu File.Save xxx.sln As , then save the Visual Studio solution where you want. In your next VS session, you can reload from menu File.Recent solutions and projects.
  • It is possible to attach to a running process from Visual Studio
  • Run Freeciv from the Test directory.
  • With the Visual studio project solution that you saved with the above settings
  • menu Tools.Attach to process Scroll down in the list to process named freeciv-gtk2.exe, and click attach.
  • Menu Debug.Break All
  • click toolbar item Thread, and select Main Thread.
  • Use Call stack at the bottom of your screen to see the freeciv call points you are interested in.