You are on page 1of 11

Microsoft Visual C++ Guide - WxWiki

Microsoft Visual C++ Guide
From WxWiki
This guide outlines the steps for building the wxWidgets This article applies to the following versions library, building and running the included samples, and outlines Platform wxWidgets Visual C++ two separate ways of setting up your own project (the first by 2.6.6 hand, and the second by copying one of the wxWidgets sample 2.8.6 projects). This is an informal, complementary guide to the Windows XP 2008 Express Edition 2.8.8 official wxWidgets MSW installation docs included with 2.8.10 wxWidgets at docs\msw\install.txt (which can also be found online ( Windows 7 2.9.3 only 2010 Professional Edition Status: Current /WX_2_8_BRANCH/docs/msw/install.txt) ), please read all of

Related Articles Visual C++ 2008: Visual Studio 2008 (9.0) Visual C++ 6.0: User's Guide For VCpp 6.0 MSVC Setup Guide Installing wx 2.4 with VisualStudio 6 Visual C++ Toolkit 2003: Installing WxWin For MS Free Tools Video Tutorials Setting up wxWidgets 2.8.10 ( Download, install, compile, and test wxWidgets 2.8.8 ( Download the wx.vsprops file (

the "Microsoft Visual C++ compilation" section before following this guide for important installation notes not covered here. If you run into any problems, check the troubleshooting section first, then all of the wxWidgets FAQs, and failing those, you can try the mailing lists, forums, or IRC.

1 Version information 2 Getting started 2.1 Downloading and installing wxWidgets 2.2 Changing setup settings 2.3 Opening the workspaces 2.4 wxWidgets build configurations 3 Building wxWidgets 3.1 Batch building all 3.2 Building single configurations 3.3 Building output 4 Building the wxWidgets samples 5 Creating a new project by hand

1 of 11

08-06-2012 10:09 PM

Released as a major upgrade to 7.0 VC6 Aka Comments Released in 1998. with limitations ( /details. This version was known to contain some major bugs at release. As opposed to 2005.8 Not Supported) The latest current release of Visual C++.0 fixing a number of issues.. The Express Edition (https://www.1.0 Visual C++ 2008 Visual C++ 9. 5. The instructions below apply to all versions of Visual C++ from Visual C++ .0 to is available for free.9.NET 2002 Visual C++ 7. Be sure to install the last service pack 6 (http://www. Version Visual C++ / Visual C++ 2010 Visual C++ 10.WxWiki http://wiki.8 and 2.. Be sure to check the troubleshooting section for known version specific issues if you run into any. with limitations (http://www.Microsoft Visual C++ Guide . with Compilation and execution of a Sample Program 10 Visual Studio C++ 2010 11 Troubleshooting 12 See also 13 External links Version information It is recommended that you use Visual C++ 2008 Express Edition (https://www.aspx?FamilyID=727BCFB0-B575-47AB9FD8-4EE067BB3A37&displaylang=en) .3 /products/2008-editions/express) . wxWidgets is compatible with every version of Visual C++ listed below if you need to use an older or newer version for some /visualstudio/en-us/products/2008-editions/express) is still available for The Express Edition (http://www. including for commercial use (or one of the other 2008 editions such as Professional if you need features not included in the Express Edition). This version contains a few improvements to Intellisense and additional STL debugging features. the Express Edition of this version includes the Windows Platform SDK making it much easier to setup applications built on wxWidgets than in (Warning: wxWidgets 2.0 Visual C++ .available for free.9+). including for commercial use.NET 2003 Visual C++ 7.0 (since wxWidgets does not use the managed extensions anyway) or upgrade to at least 7.0 2 of 11 08-06-2012 10:09 PM .org/Microsoft_Visual_C++_Guide#Visual_Stud. and it's highly recommended developers either stick with 6.0) Express Edition). The compiler and linker were released for free in the Visual C++ Toolkit 2003 (which has now been taken down in favor of using Visual C++ 2005 (8.aspx?FamilyId=A8494EDB-2E89-4676A16A-5C5477CB9713&displaylang=en) as well.1 Visual C++ 2005 Visual C++ 8.1 Project properties 6 Creating a new project from a sample 7 Visual C++ 2005 Express and text editor of your choice 8 Visual Studio C++ 2008 Professional 9 Visual Studio C++ 2010 Express and wxWidgets 2. including for commercial use. The Professional Version can also be used. (Recommended) (works best with wxWidgets First edition of Visual C++ to include managed extensions to the C++ language shared with Visual Basic and Visual C#.

(You might also want to have a look at Understanding wxWidgets Build Scheme. and the second is setup for building dynamic libraries. ANSI or Unicode. Both contain configurations for static and dynamic libraries. the wxWidgets workspace contains multiple configurations for all subprojects (Debug or Release. If you are not familiar with what these are or how they work. Getting started Downloading and installing wxWidgets Please see Downloading and installing wxWidgets (be sure to check the troubleshooting section if you are using wxALL. For OpenGL support.h..wxwidgets.aspx?FamilyID=727BCFB0-B575-47AB9FD8-4EE067BB3A37&displaylang=en) .org/Microsoft_Visual_C++_Guide#Visual_Stud. and will work in all version of Visual C++ from 6. Static or Dynamic.aspx) .0. Once opened (and converted if necessary). the OpenGL library has already been installed on your system. You also need to have OpenGL headers and libraries on your computer to be able to build with this option. please read WxWidgets Build Configurations before continuing onward. See What's New in Visual C++ 2010 (http://msdn. Universal). The settings that could be of interest are stored as defines in the file and compile the wxWidgets library.) Building wxWidgets 3 of 11 08-06-2012 10:09 PM . you will be asked about converting the project files for the version you are using.0 format simply for backwards compatibility. This is expected behavior. located in "include\wx \msw\". you might need to change some specific setup settings before building wxWidgets.0 to 10. and you can safely answer "Yes To All" when opening any of the project or workspace files. If you are using a version of Visual C++ other than 6.h for version If you are running Windows 98/Me/NT/2000/XP/2003/Vista. you need to set wxUSE_GLCANVAS to 1 (located at line 1006 of setup. The first has subproject dependency information setup for use when building static libraries. /details. The wxWidgets project files distributed for Visual C++ are currently saved in the Visual C++ 6.Microsoft Visual C++ Guide .11 of wxWidgets) before building wxWidgets. but you may run into problems building those configurations using the wrong workspace.WxWiki http://wiki. wxWidgets build configurations You are now ready to open the wxWidgets workspace file of your choice.0. The files are saved in the 6.8.dsw" and "build\msw\wx_dll.0 file format.dsw". Opening the workspaces wxWidgets contains two separate Visual C++ workspaces used to build wxWidgets using MSVC: "build\msw\wx.. Changing setup settings Depending on what you want wxWidgets for. CVS or daily snapshot sources).

Building single configurations one at a time will usually take 5 to 10 minutes per configuration. Batch building all 1. wxpng. check the troubleshooting section. but in practice it tends to be easier since most users run into fewer problems this way. base. At this point. If this happens. this means that you have a problem involving something else.dsw or wx_dll. net. Click the "Select All" button to select all projects and configurations (a total of 320 in wxWidgets 2. ~BruceKahn) Use the time now to go watch a movie (I recommend The Fifth Element ( 2. this method of building wxWidgets should take more steps. If you come back to find failed builds and are not sure how to fix it. you can figure out which configurations you really Click "Build" to start building wxWidgets. be aware that you will almost certainly run into problems building specific projects in certain configurations. or figure out what's wrong with them and fix them as you go. wxtiff." from the Build menu.Microsoft Visual C++ Guide . Read the 2 paragraphs below. odbc.WxWiki http://wiki. In theory. Repeat the steps above until all configurations build successfully. you hopefully have a good idea of what configurations you will need to build. wxregex. wxexpat. When projects (or whole configurations) fail to compile you will need to either make sure they are not ones you need. and you will know for sure when configurations you need failed to build. the mailing lists.8). and IRC. If the computer you are compiling wxWidgets on has a multi-core CPU (most newer processors these days). wxWidgets makes every effort to keep these in working order. (I have found that if I manually set the Project Dependencies in MSVC before I do any builds. the FAQs. simply build as described above and MSVC will build in the correct sequence each and every time. and is slightly more complex. 4 of 11 08-06-2012 10:09 PM . and use the single configuration build method Building single configurations Build all libraries you need one by one. Then start at the bottom of the list shown below and make each one dependent on the one above it. and will take up as much as 10GB of disk space. This has been known to cause Visual C++ to ignore wxWidgets project dependencies which can result in the failure of some projects to build correctly. Alternatively. If you batch build all ). from the menu. forums.html) .. Select "Batch Build. You should also note that batch building everything will take anywhere from one to two hours (assuming you don't run into problems). Visual C++ will attempt to build multiple projects simultaneously on each core.. 3... Simply right click on the solution name in the Solution Explorer and select Project Dependencies. I do not have to repeat the process multiple times. projects. If you don't already have either the wx. Once you have done this. 4. core.dsw (both explained above) workspace open.. in the following order: wxjpeg. Skip down to the Building Single Configurations section if you would rather use this method. but there are a lot of different configurations. wxzlib. or get a head start reading the wxWidgets Manual (http://wxwidgets. and will result in only needing 400 to 800 megabytes depending on which configurations you need. or changing your active configuration to the ones you need and building those. and lastly. The basic process of building wxWidgets involves either batch building all configurations. do so now. Using this process can help with pinpointing problems with the build. and distribution methods that can play a part in you can simply just tell Visual C++ to build the solution again until it successfully builds any remaining projects that failed to build. If the number of projects that fail stays the same between two builds.

WxWiki $(WXWIN)\include\msvc .Z\INSTALL-MSW. adv.DSW file in . xml. richtext Check your file : "wxWidgets-X. additional include directories.lib extension.wxwidgets. (I suggest to check the "empty project" checkbox [or unselect "precompiled header" for static libs] so you can start really clean. Category: Preprocessor: Preprocessor definitions: WIN32 .. which you already have build (in 'Steps to build all wxWidgets projects') Build Creating a new project by hand The main things to worry about with project settings are the C runtime library.The location of the wxWidgets include directory.NET Hit yes to convert Select the same build you did above (in 'Steps to build wxWidgets') Build However. libraries that your program needs. libraries that wxWidgets needs. don't forget that until you have a .Required __WXMSW__ .. xrc. html.txt" Building output The libraries created by the build process are located under \lib\vc_lib and will have . this may result into rebuilding the wx libs/dlls again. If you had already built these.Y.NET Hit yes to convert Remove those projects from the sample solution.This automatically includes the build-specific setup. gl. Building the wxWidgets samples Open the sample's . or Multi-Byte depending on what you need. qa. Detect 64-bit Portability Issues: Select No to avoid warning messages on strings. do following instead: Open the sample's .Required WINVER=0x0400 .Microsoft Visual C++ Guide . and the disabling of certain default libraries to resolve symbol conflicts that might occur.cpp file inside the project. dbgrid. the C/C++ won't appear under "configuration settings" in the project's properties -DL) Project properties General Character Set Select Not Set. For a list of possible files see Library files under Windows. Start with a Visual C++ Win32 Project and accept the default settings.Required 5 of 11 08-06-2012 10:09 PM .h files. Also. C/C++ Category: General Additional include directories: $(WXWIN)\include . aui.DSW file in . media. preprocessor definitions. Unicode.

__WXMSW__.WXUSINGDLL.lib wxbase28.lib (release) .Add this if you are using Unicode (note that this definition may be inherited from a project default .See the Tips'n'Tricks section of the wiki for setting up precompiled headers Linker: Category: General Additional Library Directories $(WXWIN)\lib\vc_lib (static) or $(WXWIN)\lib\vc_dll (dll) ._DEBUG.wxWidgets needs these.. If you get something like MSVCRT.Required WXUSINGDLL .lib wxtiff[ud]." warnings.lib wxbase28[ud].wxwidgets.lib wxbase28d.dll) : error LNK2005: _free already defined in LIBC.lib lib\vc_lib\mswd wxmsw28d_core. You may need to uncheck this tick box.. Category: Code Generation For the C runtime /stable/wx_debuggingoverview.The core Wx libraries.__WXDEBUG__.The location of the wxWidgets lib directory. etc.lib rpcrt4.Enables debugging __WXDEBUG__ . Activates wxASSERT().lib wsock32.lib . Note.lib wxzlib[ud].lib winmm. wxUSE_GUI=1.lib wxjpeg[ud].lib wxbase28d.lib wxbase28ud._CRT_SECURE_NO_DEPRECATE. Complete string: WIN32.see note below) _DEBUG . as the multithreaded DLL libraries are the ones wxWidgets is linked with by default.lib advapi32.Wx support libraries (optional.lib wxbase28u.lib Description release ANSI static debug ANSI static lib\vc_lib\mswu wxmsw28u_core.lib .obj) then you're linking with the wrong runtime library.lib comctl32.html) for more information. Category: Input Additional Depenedencies: wxmsw28[ud]_core. _CRT_NONSTDC_NO_DEPRECATE . See the Debugging Overview (http://wxwidgets. wxpng[ud].Add this for debug builds that link to wxWidgets debug configurations. Consider using <alternative> instead.lib debug Unicode static Linking with correct runtime library Runtime Library name Switch CRT library file Macro(s) Defined wxWidgets options Description 6 of 11 08-06-2012 10:09 PM .Add this if you want to suppress "This function or variable may be unsafe. _CRT_NONSTDC_NO_DEPRECATE Note that some preprocessor definitions may be included if the "Inherit from parent or project defaults" checkbox is ticked (which is the default). _WINDOWS . Category: System SubSystem Set Windows (/SUBSYSTEM:WINDOWS) Core wxWidgets libraries to include Directory Basic wxWidgets libraries lib\vc_lib\msw wxmsw28_core.lib release Unicode static lib\vc_lib\mswud wxmsw28ud_core._WINDOWS. for debug ANSI static: wxmsw28d_core. For example.lib(MSVCRT.Microsoft Visual C++ Guide . modify file names according to need).org/Microsoft_Visual_C++_Guide#Visual_Stud.If you're compiling using DLLs instead of a static build wxUSE_GUI=1 . _CRT_SECURE_NO_DEPRECATE .Suppresses other warnings.lib(free.Add this for projects using GUI components (optional) _UNICODE .WxWiki http://wiki. Category: Precompiled Headers Create/Use Precompiled Headers: Not using Precompiled Headers . you need to choose the correct ones according to the table below. use the Multithreaded DLL (/MD) for release and Debug Multithreaded DLL (/MDd) for debug builds.WINVER=0x0400.

..sln.Microsoft Visual C++ Guide . Search replace "internat" with "myapp". This tutorial takes the simple (and usually best) route. Open myapp. this is also an option. Save and close.vcproj and internat.6. Use the $(WXWIN) variable and relative paths whenever possible. Visual C++ 2005 Express and text editor of your choice If all else fails (although I wish I had tried this earlier)... This will create internat.\. If you can get a sample to build.) 7 of 11 08-06-2012 10:09 PM ." with "c:\wxWidgets-2.2" or wherever you installed wxWidgets to. So you should search and replace the duplicate GUID by a unique one in the .) Search replace "...sln in Visual Studio . Try searching and replacing ". Open myapp./. Search replace ".6.2 and VC8 Express or VC .NET as above. The uniqueness of the ProjectGUID (http://msdn2. is all you need.\.NET 2003 (7. You are doing two things at once.\.wxwidgets. (Otherwise it should only matter in . then edit it so that it only contains a single Configuration (such as "Release|Win32"). of copying a sample's project file. AdditionalDependencies.dsp to Visual Studio .lib _MT _DEBUG Debug BUILD=debug RUNTIME_LIBS=dynamic Multithreaded DLL /MD MSVCRT. the above will yield odd results.NET applications. Otherwise. and is less error prone than manually creating a project file. Note that you can add the wxWidgets include/lib paths to your Visual Studio's search paths (under Tools>Options>Projects>VC++ Directories).vcproj and myapp. open the sample's converted . specifying your path to wxWidgets directly in the project. This must match the build under which you compiled wxWidgets. as described above.lib _MT release static debug static release dynamic debug dynamic Creating a new project from a sample If you have trouble with the above method. Save and close. First convert samples\internat\internat. and OutputFile attributes and make sure they are what you expect.. according to Microsoft.. A single configuration may lose some functionality but makes it harder to screw up the file." with "c:\wxWidgets-2.vcproj and to your application directory. preparing your app for building and making sure the project reflects your preferred code organization.lib Debug DLL _DLL BUILD=debug Multithreaded /MT LIBCMT. This is recommeded if you will be working with anyone else on the project.WxWiki http://wiki. RUNTIME_LIBS=static BUILD=release Multithreaded RUNTIME_LIBS=static /MTd LIBCMTD.2" or wherever you installed wxWidgets to. you should be able to use this method without issues. because it brings up all the samples! In the text editor.vcproj in notepad.2" or wherever instead. IntermediateDirectory.lib _MT _DLL BUILD=release Multithreaded _MT _DEBUG RUNTIME_LIBS=dynamic /MDd MSVCRTD.1).NET.. Copy internat." with "c:\ pay close attention to the OutputDirectory.vcproj and .sln files. AdditionalIncludeDirectories. In fact the solution file will be counterproductive if you built all the samples at once. Search replace ".6.\.sln.vcproj file in a text editor and take a close look at what the paths should setting is necessary to calculate the build order correctly from the project dependencies. it will get created automatically. This automatically sets up all the right build configurations. Search replace "internat" with "myapp".2" or wherever you installed wxWidgets to. Add more info to this wiki if you find this to be true of other combinations. The solution file is of no value..6." with "c:\wxWidgets-2. add your source files to the project and build. Open myapp. Search and replace the sample name with your app name. (Note: with wxWidgets 2.sln in notepad. rename as myapp.

Note: at time of writing (25/09/2010).com/2009/12/16/how-to-compilea-wxwidgets-application-in-visual-studio-2008/) Please provide feed back and we can migrate this documentation to this wiki. Because many Projects have dependencies which are not satisfied immediately. Now reopen the . Search for 'Path' -> 'Edit'.7-Zip File (only 12 MB ! ).vcxproj. close VC. and then Just Append .9. it is recommended to carry out the 3 following simple steps: 8 of 11 08-06-2012 10:09 PM .wxwidgets.sln / *. Basically the process should be to go to C:\wxWidgets\build\msw .C:\wxWidgets\lib\vc_dll to the End.dsw -> create *. Now. If the . and Press F7. for building wxWidgets with VC++ 2010. Download wxWidgets.ZIP File if you wish instead of .vcxproj) in a text editor and use Find & Replace to replace all occurrences of $(Input) with %(Identity). Then Choose 'DLL-Release Win32' on Top. and Open drawing_vc9 Project. Right-Click on My-Computer -> Properties -> Advanced System Settings -> Environment-Variables -> User-Variables. Visual Studio C++ 2008 Professional The following steps work on Visual Studio C++ 2008 Professional and will probably work on Express as well.3 is to keep Pressing F7 Againand-Again-and-again.vcproj) -> open *. then you would want to Compile 'DLL-Debug' Release in the same manner as described above. I just go to individual Project Folder...sln in VS C++ 2010 (create -> *. as your .EXE can now easily find DLLs.exe' ready-to-be-run ! Visual Studio C++ 2010 The wxWidgets Custom build rules in default uses "$(Input)" instead of the new "%(Identity)" for all the custom build rules.. I downloaded the . you have your 'drawing. Visual Studio C++ 2010 Express and wxWidgets 2. then Convert it as Prompted. C:\wxWidgets\samples\drawing. and then hit F7 to create Release Version. Then keep Pressing F7 again and again till you get '0 Failed' Message below. Now. When you are packaging. try conversion via VS C++ 2008 (open *.Microsoft Visual C++ Guide . so it is necessary to keep compiling with 'F7' till all are satisfied. then you obviously need to bundle specific Release-DLL'S along. and installed it at C:\wxWidgets .WxWiki http://wiki. In case of problems while importing the original VC++ 6 workspace (*. You can download the . This makes running your compiled Application easier.vcproj file in the IDE and remove the bogus files (left over from the sample) and add the real files. Wait for Compilation to take place and see the Message. and convert it to VC-2010 when asked.7-zip. and open wx_vc9 Solution File for VC-2008.3 Compilation.. To Add vc_dll Folder to your PATH.. fire up the text editor again and move the File elements so that they are inside the Filter elements and then close and reopen in VC8.cpp files you added do not appear under Source Files. Then you can compile the Samples located at C:\wxWidgets\samples. How to compile a wxWidgets application in Visual Studio 2008? (http://rhyous. Now if you go inside C:\wxWidgets\samples\drawing\vc_mswudll\ Folder. with Compilation and execution of a Sample Program The Key to Compilation using Visual C++ 2010 Express and wxWidgets 2. this step may be slow).. Once you are done compiling DLL-Release Version..dsw).g. like for e. Open all project files (. The compiled DLL Files can then be found at C:\wxWidgets\lib\vc_dll. the Structure of your extracted wxWidgets Source should be like so that you see the following Folders like C:\wxWidgets\lib and C:\wxWidgets\build etc till you you get '0 Failed' Message below.

Download wx291_msw_vc10.vcxproj files in a texteditor replace the string $(INTDIR) $(OUTDIR). The path is not of a legal form. 6.. 5. 1. 4. open wx_vc10.sln Go through with the conversion process Close the Visual Studio Open all the newly created *.wxwidgets. In build/wx291_msw_vc10.$(OUTDIR).php?t=27630) .CppCommon.Microsoft Visual C++ Guide . A potential workaround is as follows: .wxwidgets. 2.targets(151. Open wx_vc9. select a configuration (for example "DLL Release") and hit F7 until all 22 projects are built successfully (see below screenshot). 1. The error should not appear 9 of 11 08-06-2012 10:09 PM .exe". 2.\ from this page (http://forums.exe installer.% with $(INTDIR).WxWiki http://wiki..sln again Build as expected. .sln.% (note the added semicolon) Open wx_vc9. 3. Unzip it in the "build" directory.5): error MSB6001: Invalid command line switch for "cmd. Download and execute the 2. 3. Note: at time of writing (09/11/2010) A Bug in the conversion process of Visual C++ Express 2010 may cause an error similar to: 1.

com/kb/140584) Herb Thompson's build report (http://wxforum. Troubleshooting See Troubleshooting building wxWidgets using Microsoft VC.with the steps he followed (Visual C++ 2008 Express & wxWidgets 2.html) .Many useful project templates and code snippets.a German tutorial for wxWidgets Compiling & Using wxWidgets ( .7.php?t=16890&highlight=) .Microsoft Visual C++ Guide See also WxMSW Issues External links How to link with the correct C Run-Time (CRT) library (http://support.xs4all.shadonet.7 and VS 2008 (9.8. wxCRP is abandoned and replaced with CodeVolution 10 of 11 08-06-2012 10:09 PM .8.0) wxCRP (http://www..WxWiki http://wiki.

wxwidgets. at 05:15. which makes it easier to find those pesky memory leaks.wxwidgets.xs4all.. 11 of 11 08-06-2012 10:09 PM .org/Microsoft_Visual_C%2B%2B_Guide" This page was last modified on 23 February 2012.litwindow. How to find the file and line number of memory leaks using C++ with wxWidgets in Visual Studio 2008? (http://rhyous. CodeVolution (CVL) (http://www.Visual Studio will show you memory leaks when you close the program after debugging.wordpress.Microsoft Visual C++ Guide .com/2009/10/13/how-to-find-the-file-and-line-number-of-memory-leaks-usingc-with-wxwidgets-in-visual-studio-2008/) . but will not show you the line yet released to the public) Lit Window Productions (http://www. With this setup the line number shows. How to compile a wxWidgets application in Visual Studio 2008? ( : Additional help and tools for using wxWidgets with Visual Studio (Commercial) Retrieved from "http://wiki.html) .nl/~jorgb/wb/MyProjects/CodeVolution.WxWiki http://wiki.