Step 1 – Install Visual Studio 2008
- If you don’t have it, get the express edition here: http://www.microsoft.com/Express/VC/
- Run through the installer, not much else to do.
Step 2 – Install wxWidgets
- Download wxWidgets (select the wxMSW installer file) from here:
http://www.wxwidgets.org/downloads/ - I choose to install to c:\dev\wxwidgets\wxWidgets-2.8.10 but you can choose a different path if you want.
Step 3 – Create an environment variable for the wxWidgets path.
- Click the Start icon.
- Right click on Computer and choose Properties.
- Click Advanced system settings.
- Click the Environment variables button.
- Under System Variables, click New.
- Enter the Variable name: WXWIN
- Enter the Variable Value: C:\Dev\wxWidgets-2.8.10
- Click OK, click OK, click OK (yes three times).
Step 4 – Compile the wxWidgets Libraries.
- Browse to the following folder: C:\Dev\wxWidgets-2.8.10\build\msw
- Located the file called wx.dsw and open it with Visual Studio. (I just double-clicked on it.)
- Choose “Yes to all” when Visual Studio prompts you to convert the project.
- Build the project.
- Wait for the build to complete. It took approximately two minutes on my Lenovo T61p (dual core, 4 GB, Windows 7 64 bit). You should a line like this when it finishes successfully.
========== Build: 20 succeeded, 0 failed, 0 up-to-date, 0 skipped ==========
- Close Visual Studio.
Step 5 – Create a new project
- In Visual Studio 2008, go to File | New Project.
- Select Visual C++ | Empty Project.
- Give the project a name and click OK. I named this wxTest.
Step 6 – Create/Copy your source to this project.
- Right-click on the Project name and choose Open Folder in Windows Explorer. This will open to the home folder of your project. (Don’t right click the Solution name, make sure to right click the project under the solution name.)
- Open a second Windows Explore window.
- In the second window, browse to the wxWidgets sample directory and open the Minimal folder: C:\Dev\wxWidgets-2.8.10\samples\Minimal
Note: You can choose other projects but you may want to start with Minimal and move on from there. - Copy only the minimal.cpp and minimal.rc files to your project directory (the rest are not needed).
- Close the second window pointing to the C:\Dev\wxWidgets-2.8.10\samples\Minimal directory, it is not needed anymore.
- From the explorer window open to your project directory, use ctrl+click to highlight both the minimal.cpp and minimal.rc files.
- Drag both highlighted files into the Visual Studio Window and drop them over the project name.
The minimal.cpp file should automatically be placed under the Source files section of your project.
The minimal.rc file should automatically be placed under the Resource files section of your project.
Step 7 – Customize the project properties
- Right-click on the wxTest project and select Properties. (Don’t right click the Solution name, make sure to right click the project under the solution name.)
- In the top left of the properties window there is a Configuration drop down menu. Select All Configurations.
- Click to expand Configuration Properties.
- Click to expand C/C++.
Note: If you don’t see a C/C++ section, then you don’t have any source files. You need at least one C++ source file for this section to show up.
- Click to highlight General.
- Enter the following in Additional Include Directories.
$(WXWIN)\include;$(WXWIN)\lib\vc_lib\mswd
- Click to highlight Preprocessor.
- Enter the following in Preprocessor Definitions.
WIN32;__WXMSW__;_WINDOWS;_DEBUG;__WXDEBUG__
- Click to expand Linker.
- Click to highlight General.
- Enter the following in Additional Library Directories.
$(WXWIN)\lib\vc_lib
- Click to highlight Input.
- Enter the following in Additional Dependencies.
wxmsw28d_core.lib wxbase28d.lib wxtiffd.lib wxjpegd.lib wxpngd.lib wxzlibd.lib wxregexd.lib wxexpatd.lib winmm.lib comctl32.lib rpcrt4.lib wsock32.lib odbc32.lib
Note: Not all of these libraries are required for this project, however, I list all of these because you may use some of them at some point. If you don’t think one is needed, remove it and recompile and if you don’t get errors, you were right, you probably didn’t need it.
- Click to expand Resources. (If you don’t see a Resources option, then you don’t have any files under resources so that is normal. Did you skip Step 5 because you probably should have added a resource in Step 5.)
- Click to highlight General.
- Enter the following in Preprocessor Definitions.
_DEBUG;__WXMSW__;__WXDEBUG__;_WINDOWS;NOPCH
- Enter the following in Additional Include Directories.
$(WXWIN)\include;$(WXWIN)\lib\vc_lib\mswd
You are now ready to build your wxWidgets application using Visual Studio 2008 on Windows 7.
Build your project and if you get any errors, go through it again, you probably missed a step (or I did, since I have already been caught with one step left out).