Visual Studio 2008 (9.0)

From WxWiki
Jump to: navigation, search

WxWidgets applications can be build using the free Visual Studio 2008 Express Edition which is available from : http://www.microsoft.com/express/vc/Default.aspx.

Building wxWidgets 2.8.7 for Visual Studio 2008 / VCpp 9.0 is as simple as : nmake -f makefile.vc However this creates a debug build that links with the dynamic libraries.

Static library linking is much more useful for making the application portable. The following command generates a release build with static libraries : nmake -f makefile.vc RUNTIME_LIBS=static BUILD=release

The following bakefile works with the above wxWidgets build :

<?xml version="1.0" ?> 

<!-- $Id: make.bkl,v 1.0 2005/05/11$ --> 

<makefile>
    
    <!-- Additional include paths (include tag) -->

    <set var="EXTRAINCLUDE"></set> 

    <include file="c:/wxMSW-2.8.7/build/bakefiles/wxpresets/presets/wx.bkl" />

    <exe id="Application" template="wx">
        <app-type>gui</app-type>
        <debug-info>off</debug-info> 
        <runtime-libs>static</runtime-libs>
        <threading>multi</threading>

        <syntaxhighlights>
            Application.cpp
        </syntaxhighlights>
        <wx-lib>adv</wx-lib>
        <wx-lib>net</wx-lib> 
        <wx-lib>core</wx-lib> 
        <wx-lib>base</wx-lib>
        <win32-res>Application.rc</win32-res>
	</exe>
</makefile>

The following command line will build the application :

nmake -f makefile.vc BUILD=release WX_DEBUG=0


Some additional notes:

You can also use MSVC 2008 Professional (aka V9.0).

MS recomends to not mix libs from different versions of the compiler. Strange link erors might be the result.

So it is a good idea to create a dir msv9 and copy the contents of the msw dir into it. Then open the wx.dsw. MSVC9 will ask you to convert it to its own format. Accept this and all projects in the work space will be converted from .dsp to .vcproj. The wx.dsw will be wx.sln.

From now on you don't need the old MSVC6 projects any more.

If you have several version of MSVC installed and want to keep the libs real separate, it is best to open the .vcproj files with a good editor and replace the following entries (can someone make SED scripts?):

vc_lib to vc_lib9

vc_lib9/ to vc_lib9\

vc_dll to vc_dll9

vc_dll9/ to vc_dll9\


The MSVC6 project files have an error and use the DLL build even for the static builds. That should be corrected. If you don't care about the DLL-Builds, you can do a global replace in all .vcproj files, otherwise you need to do it for each subproject. (I will try to get the .dsp fixed in future releases, current: 2.8.9)

CAUTION: Also changes the DLL builds!!

RuntimeLibrary="3" to RuntimeLibrary="1"

RuntimeLibrary="2" to RuntimeLibrary="0"

The same procedure must be done for the samples.