Compiling wxWidgets with Visual Studio 2010

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:

  1. Open a command window.
    Start Menu - Run - cmd

  2. 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
    prompt> vcvarsall.bat

  3. Create a WXWIN environment variable pointing to the extract location of the wxWidgets library. prompt> set WXWIN="c:\libs\wxWidgets\wxWidgets-2.8.11"

  4. Change directory to the msw build sub-directory.
    > cd %WXWIN%\build\msw

  5. And now issue the build command(s) of interest.

    Multibyte Build Commands

    > nmake -f UNICODE=0 BUILD="debug" SHARED=0
    > nmake -f UNICODE=0 BUILD="debug" SHARED=1
    > nmake -f UNICODE=0 BUILD="release" SHARED=0
    > nmake -f 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.

    > nmake -f UNICODE=1 BUILD="debug" SHARED=0
    > nmake -f UNICODE=1 BUILD="debug" SHARED=1
    > nmake -f UNICODE=1 BUILD="release" SHARED=0
    > nmake -f UNICODE=1 BUILD="release" SHARED=1

    nmake -f invokes nmake on the file ''

    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.

  6. Observe your libs appearing in %WXWIN%\lib\vc_lib and DLLs appearing in %WXWIN%\lib\vc_dll as the compilations progress.

  7. 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 :)


Post a Comment

What are your thoughts?