Compiling the wxWidgets libraries with Visual Studio 2010 is easy if you use the Visual Studio compiler at the command line (nmake). In the 2010 edition, converting vanilla wxWidgets projects from .dsw to .vcxproj format is an operation that fails. The command line provides a workaround and the steps are as follows:
- Open a command window.
Start Menu - Run - cmd
- Change directory to the Visual Studio environment variables folder then load the environment variables into the command window session.
As an example, If Visual Studio 10.0 was installed to C:\Program Files, the following actions would work:
prompt> cd C:\Program Files\Microsoft Visual Studio 10.0\VC
- Create a WXWIN environment variable pointing to the extract location of the wxWidgets library.
prompt> set WXWIN="c:\libs\wxWidgets\wxWidgets-2.8.11"
- Change directory to the msw build sub-directory.
prompt> cd %WXWIN%\build\msw
- And now issue the build command(s) of interest.
Multibyte Build Commands
prompt> nmake -f makefile.vc UNICODE=0 BUILD="debug" SHARED=0
prompt> nmake -f makefile.vc UNICODE=0 BUILD="debug" SHARED=1
prompt> nmake -f makefile.vc UNICODE=0 BUILD="release" SHARED=0
prompt> nmake -f makefile.vc UNICODE=0 BUILD="release" SHARED=1
Unicode Build Commands
Unicode requires an extra step so as to enable the unicode pre-processor directive: use your favorite text editor to open the file %WXWIN%\include\wx\msw\setup.h then change "#define wxUSE_UNICODE 0" to "#define wxUSE_UNICODE 1" Save the file then issue the build commands below.
prompt> nmake -f makefile.vc UNICODE=1 BUILD="debug" SHARED=0
prompt> nmake -f makefile.vc UNICODE=1 BUILD="debug" SHARED=1
prompt> nmake -f makefile.vc UNICODE=1 BUILD="release" SHARED=0
prompt> nmake -f makefile.vc UNICODE=1 BUILD="release" SHARED=1
nmake -f makefile.vc invokes nmake on the file 'makefile.vc'
UNICODE=0 or 1 produces the multi-byte or wide-character builds respectively.
BUILD="debug" or "release" produces the debug and release builds respectively.
SHARED=0 or 1 generates static libs or DLLs respectively.
- Observe your libs appearing in %WXWIN%\lib\vc_lib and DLLs appearing in %WXWIN%\lib\vc_dll as the compilations progress.
- Optionally clean up intermediate files to save disk space.
Navigate to %WXWIN%\build\msw and delete the sub-folders: vc_msw, vc_mswd, vc_mswu, and vc_mswud
You're done! Happy app building :)