WindowsMicrosoft Visual Studio
Before covering the step-by-step directions for creating wxWidgets projects with Visual Studio, it should be noted that there are alternatives for generating Visual Studio project files using third-party tools. Although not covered here, utilities like DialogBlocks, wxHatch, wxWinWizard, and wxVisualSetup can be used to generate project files that can be loaded and used in Visual Studio. If you want detailed control over your project or need to make specific modifications, however, it may be necessary to have an understanding of the individual settings.Microsoft Visual Studio enables you to quickly and easily build wxWidgets projects by adding just a few wxWidgets directories and files into your project settings. Although the exact location for each setting is slightly different in each version of Visual Studio, the options are named roughly the same; please look at nearby options or consider alternate wordings if the setting isn't listed exactly as specified here.
Troubleshooting
If you receive any compile or link errors when building, double-check that you carefully followed all of the steps in the previous section to specify the include directories, the library directories, the wxWidgets and Win32 libraries, and the correct run-time library. You can also compare the project settings in any of the samples to the settings in your own project, looking for any discrepancies. Some developers start with a sample application's project file so that most of the settings are already defined correctly.Some common error messages and solutions include the following:
- Cannot open include file: 'wx/wx.h': No such file or directory
This happens in two situations. One, the library itself hasn't been compiled yet; see Appendix A. Two, the library's include directory cannot be found (for example, c:\wxWidgets\lib\vc_lib\mswd); check that it is listed in the additional include directories. - Cannot open include file: 'wx/setup.h': No such file or directory
The library's include directory cannot be found (such as c:\wxWidgets\ lib\vc_lib\mswd); check that it is listed in the additional include directories. - Cannot open file wxmswXXXX
Either the libraries haven't been compiled or the wxWidgets libraries cannot be found because the directories have not been added to the additional library paths. Ensure that the library directory containing your compiled wxWidgets library has been added to the additional libraries. - Unresolved symbols to wxWidgets classes
Some or all of the necessary wxWidgets library modules could not be found. Examine the symbols listed to determine the missing libraries, check the previous list of libraries, and add any missing library modules. - Unresolved symbols to Windows functions
The linker could not find the Windows symbols needed to link your application. Ensure that the Windows libraries are included in the list of modules to be linked.
Using Multiple Configurations
Visual Studio creates two project configurations, debug and release, when you create a new project. Most wxWidgets developers test their applications using a debug build of wxWidgets to benefit from the debug information and the run-time assertions that may indicate certain problems. You will need to re-enter most of the settings for each different project configuration that you use keeping in mind which wxWidgets build the project configuration will be using. To save some time, you can copy one configuration rather than manually re-creating all of the settings each time.The sample applications have over a dozen project configurations if you want to see how the settings may differ for each configuration.