Clone wiki

codetrainer / Compiling a wxWidgets sample with Visual Studio

Here are the steps needed to compile a wxWidgets sample with Visual Studio.

NOTE: The last step, though optional, shows how to get started in creating a new wxWidgets project. It is a way of doing though we strongly encourage you to use the cmake way for creating a new wxWidgets project.

  1. Make sure you compiled wxWidgets. This should be easily done by following the instructions
  2. Once you have compiled wxWidgets go to the samples directory. There you'll see a lot of folders, each folder containing at least one sample
  3. Let's take for example the calendar sample. Go to that folder and open calendar_vc9.vcproj project file (or a more recent version if present!) with the Visual Studio version you used to build wxWidgets
  4. Make sure you convert it to your Visual Studio version if needed.
  5. Select the configuration(s) you used to build wxWidgets and build the solution (DLL Debug, DLL Release etc). Everything should build without problems. Save the solution if asked in the calendar directory.
  6. To Run the executable you will need the wxWidgets DLLs. This can be solved by:

    6.1. Adding to PATH environment variable the place where the wxWidgets DLLs are (in our compilation instructions C:\Code\wxWidgets-3.0.0\lib\vc_dll)

    6.2. Copying the DLLs to the place where the executable is(calendar.exe is in samples\calendar\vc_mswuddll (debug) / samples\calendar\vc_mswudll (release) )

  7. To move the files into a different location you will need to update the project properties because the samples solutions contain relative paths. See picture below: calendar_relative.png This can be achieved by using the WXWIN environment variable which must correctly point to the wxWidgets folder.

    7.1 The next picture shows us how our solution configuration should be (for the compiler): calendar_absolute_wxwin.PNG

    7.2 The next picture shows how the linker should have the relative paths replaced calendar_absolute_wxwin_linker.png