Building KiCad with Visual Studio 2005 Express

GeSHi library error: sites/all/modules/geshifilter/geshi is not a directory.

I want to rebuild KiCad with one small feature changed (PCB edges disabled in printing) and I want to do this as fast as possible. Because I personally do not like MSYS, I choose Visual Studio as an option. The tutorial below is based on KiCad - Compiling and debugging originally by Geert Vancompernolle, but contains lessons learnt on this task.

  1. Download and uncompress KiCad sources.
  2. Install Visual Studio C++ 2005 Express Edition.
  3. Install Windows Platform SDK for Server 2003 R2.
  4. Install CMake (version 2.6 Patch 1 in my case).
  5. Install wxWidgets in a convenient directory (yes, they provide an installer for you called wxMSW; select for example [geshifilter-code]C:\Projects\KiCad\wxwidgets-2.8.8[/geshifilter-code]).
  6. Install Boost 1.34 (a method given by J. P. Charras). This is quite time consuming process, during which I started writing this doc. You probably should select only interesting packages, what I did not.
  7. Install and build zlib 1.2.3. (I did not do this step, because I have zlib in GTK+ directory which is found by CMake; zlib binaries are available here).
  8. In file [geshifilter-code]include/wx/setup_inc.h[/geshifilter-code] and [geshifilter-code]include/wx/msw/setup.h[/geshifilter-code], change [geshifilter-code]wxUSE_GLCANVAS[/geshifilter-code] to 1 and [geshifilter-code]wxUSE_UNICODE[/geshifilter-code] to 1.
    In file [geshifilter-code]build/msw/config.vc[/geshifilter-code], change the options as stated below:[geshifilter-blockcode]SHARED = 0 UNICODE = 1 BUILD = release MONOLITHIC = 0 USE_OPENGL = 1 USE_THREADS = 1[/geshifilter-blockcode]
  9. In [geshifilter-code]cmd.exe[/geshifilter-code] change directory to wxWidgets (I am giving my paths in all examples below):
    [geshifilter-code]cd C:\Projects\KiCad\wxwidgets-2.8.8[/geshifilter-code]
  10. Run [geshifilter-code]C:\Program Files\Microsoft Visual Studio 8\VC\bin\vcvars32.bat[/geshifilter-code] in the same command line as above.
  11. Run [geshifilter-code]C:\Program Files\Microsoft SDK for Windows Server 2003 R2\SetEnv.Cmd[/geshifilter-code] in the same command line as above.
  12. Run [geshifilter-code]nmake -f makefile.vc[/geshifilter-code]
  13. Run [geshifilter-code]CMakeSetup.exe[/geshifilter-code] (in this step I am not sure whether it makes any difference if it is clicked from meny or started from command line).
  14. In filed "Where is the source code" put the path to the KiCad source code ([geshifilter-code]C:\Projects\KiCad\kicad-20080804[/geshifilter-code] in my case).
    In field "Where to build binaries" select directory for binaries (other than src otherwise you will mess up; [geshifilter-code]C:\Projects\KiCad\kicad-bin[/geshifilter-code] in my case).
  15. Click "Configure" button and in "Build for" field select "NMake makefiles" (reference is here).
    At this step it may return errors or warning about missing path to the compiler. Do not worry.
  16. (optional) If above has happen, tick "Show Advanced Values" in main CMake window (after you confirm all the dialogues popped up) and in [geshifilter-code]CMAKE_C_COMPILER"[/geshifilter-code] put [geshifilter-code]C:/Program Files/Microsoft Visual Studio 8/VC/bin/cl.exe[/geshifilter-code] (Notice! You have to use slash not backslash here! Or you can browse the path by clicking "...").
    Finally click the "Configure" button again.
    At this stage you may get errors about wxWidgets, so you have to provide [geshifilter-code]wxWidgets_ROOT_DIR[/geshifilter-code] to the place where you have wxWidgets built.
  17. Following elements in config cache:
    • [geshifilter-code]CMAKE_CXX_FLAGS_DEBUG[/geshifilter-code]
    • [geshifilter-code]CMAKE_CXX_FLAGS_RELEASE[/geshifilter-code]
    • [geshifilter-code]CMAKE_CXX_FLAGS_RELWITHDEBINFO[/geshifilter-code]
    • [geshifilter-code]CMAKE_CXX_FLAGS_MINISIZEREL[/geshifilter-code]
    • [geshifilter-code]CMAKE_C_FLAGS_DEBUG[/geshifilter-code]
    • [geshifilter-code]CMAKE_C_FLAGS_RELEASE[/geshifilter-code]
    • [geshifilter-code]CMAKE_C_FLAGS_RELWITHDEBINFO[/geshifilter-code]
    • [geshifilter-code]CMAKE_C_FLAGS_MINISIZEREL[/geshifilter-code]

    contains /MD or /MDd options, correct them to /MT and /MTd respectively to avoid DLL compilation (this is important, but I am not VC guru, so I do not know why).

  18. At least click "OK" button which should generate makefiles for Visual Studio. You may get a warning window about some policy, but I don't think it is important only for CMake support maintainer in KiCad project.
  19. Change directory to binary directory you selected in CMake window in the same command line you use to build wxWidgets and run [geshifilter-code]nmake[/geshifilter-code]. This should start compilation process.

Above steps reflects my knowledge gathered in couple of hours spent on the problem. If you have any questions, comments suggestions please use contact form to reach me. Any thanks would be nice. too. Certainly, if you successfully build KiCad using these rules, please contact me too. I really would like to know I did not put any lies here.

Thank you.

If you want to return to wiki page, please click here.