Difference between revisions of "WxWindowsQuickRef"
(New page: A beginner's guide to setting up wxWidgets with Code::Blocks in Windows.) |
(Initial page creation, majority of content) |
||
Line 1: | Line 1: | ||
− | A beginner's | + | '''''A beginner's quick reference for setting up wxWidgets with Code::Blocks in Windows''''' |
+ | |||
+ | |||
+ | '''Important Requirements:''' | ||
+ | * '''Windows compiler''' - You need to have correctly installed the free [http://www.mingw.org/ MinGW/GCC] compiler or one of [http://msdn.microsoft.com/vstudio/ Microsoft's compilers] (the [http://msdn.microsoft.com/vstudio/express/ Express editions] are free, but you must also install the [http://www.microsoft.com/downloads/details.aspx?familyid=0baf2b35-c656-4969-ace8-e4c0c0716adb Platform SDK]). If using MinGW/GCC, you need at least the gcc-core, gcc-g++, binutils, w32api, and mingw32-make packages; also, ensure that the folder containing the compiler executables (typically C:\MinGW\bin) is in your [http://vlaurie.com/computers2/Articles/environment.htm#editing Windows PATH environment variable]. | ||
+ | * '''Nightly build of Code::Blocks''' - You need to have successfully installed and run [/index.php/board,20.0.html a recent nightly build of Code::Blocks]. | ||
+ | |||
+ | |||
+ | == Download wxWidgets == | ||
+ | You can choose to download the wxWidgets source code and compile it yourself, or download the "wxPack", a precompiled version. | ||
+ | * '''The wxWidgets sources''' are a much smaller download, but you must also spend some time compiling them. | ||
+ | * '''wxPack''' is a much larger download, but you don't have to spend time compiling it or worry about build options. | ||
+ | |||
+ | === wxWidgets Sources === | ||
+ | The current recommended version of wxWidgets to use is '''2.8.5'''. [http://prdownloads.sourceforge.net/wxwindows/wxMSW-2.8.5.zip Click here to download the wxWidgets 2.8.5 sources for Windows] (wxMSW-2.8.5.zip; 15.8 MB). You can check [http://www.wxwidgets.org/downloads/ the wxWidgets download page] to see if a newer stable version is available. '''It is highly recommended that you extract the sources to a path without spaces.''' You should choose a volume with at least 300 MB of free space. | ||
+ | |||
+ | === wxPack === | ||
+ | The current stable release of wxPack is '''v2.8.4.02''', based on wxWidgets 2.8.4. [http://downloads.sourceforge.net/wxpack/wxPack_v2.8.4.02.exe?download Click here to download wxPack v2.8.4.02] (wxPack_v2.8.4.02.exe, 222.7 MB). '''It is highly recommended that you install wxPack in a path without spaces.''' You should choose a volume with at least 700 MB of free space for MSVC, or 2.2 GB of free space for MinGW/GCC. | ||
+ | |||
+ | |||
+ | == Build wxWidgets == | ||
+ | ''This step is unnecessary if you are using '''wxPack''' '' | ||
+ | |||
+ | * Open up a command prompt for building. If you are using MinGW/GCC, simply use the standard Windows command shell (open the Start menu, click "Run...", enter "cmd" and hit OK). If you are using MSVC, you should use the special command shell which sets up the correct environment variables for you. If you use a version of MSVC which required you to download the Platform SDK separately, ensure that whichever command environment you use includes the Platform SDK tools and paths as well as the standard compiler tools and paths. | ||
+ | * Change to the wxWidgets build directory (where <wxWidgets> is the path you extracted the sources to; typically C:\wxMSW-2.8.5): | ||
+ | cd <wxWidgets>\build\msw | ||
+ | * Execute the build command. The recommended command to use for '''MinGW/GCC''' is: | ||
+ | mingw32-make -f makefile.gcc BUILD=release SHARED=1 MONOLITHIC=1 UNICODE=1 | ||
+ | * The recommended command to use for '''MSVC''' is: | ||
+ | nmake -f makefile.vc BUILD=release SHARED=1 MONOLITHIC=1 UNICODE=1 | ||
+ | * This step will generally take a long time; faster PCs may expect 30-minute build times, and slower PCs can take as much as several hours. | ||
+ | * If using more recent versions of GCC, many warnings will occur during the build. This can slow the build process noticeably; you may want to redirect the warnings to a text file by appending "2>errlog.txt" to the build command, or supress them entirely by appending "2>nul". | ||
+ | |||
+ | === wxWidgets build options explained === | ||
+ | ''What do the BUILD, SHARED, MONOLITHIC, and UNICODE options mean?'' | ||
+ | * BUILD=release indicates that we want the faster and smaller release build of wxWidgets, as opposed to the heavyweight debug build (BUILD=debug). You can still debug your own programs that use the wxWidgets release build. | ||
+ | * SHARED=1 indicates that we want to use wxWidgets from a separate DLL instead of statically linking the wxWidgets code into every program. This saves time compiling, and saves space. | ||
+ | * MONOLITHIC=1 indicates that we want all of the wxWidgets code in a single library, rather than split up into separate component libraries. This merely makes the wxWidgets library easier to work with while developing. | ||
+ | * UNICODE=1 indicates that we want Unicode-compatible strings and language support in our programs. This should always be preferred except on pre-Win2k systems, where you must either install a separate Unicode library or build with UNICODE=0. | ||
+ | ''Why are these options critically important?'' | ||
+ | |||
+ | These options define the basic wxWidgets development environment you will be using. You must duplicate them exactly when running Code::Blocks' wxWidgets project wizard. | ||
+ | |||
+ | |||
+ | == Create a wxWidgets project in Code::Blocks == | ||
+ | * On the Code::Blocks Start Page, select "Create a new project"; alternatively, open the File menu, highlight "New" and select "Project..." | ||
+ | * Select "wxWidgets project" | ||
+ | # The first page is an introduction, which you can choose to skip in the future. | ||
+ | # Select which version of wxWidgets you will be using. If you followed the instructions above, you should select "wxWidgets 2.8.x". | ||
+ | # Set your project title and location. | ||
+ | # Enter author details if you wish (not required). | ||
+ | # Select options for automatic code and file generation. | ||
+ | # Select wxWidgets' location. It's highly recommended that you use a global variable for this: enter "$(#wx)" (without quotes). If you haven't already defined this global variable, the global variables dialog will appear; for the base path, select your wxWidgets installation location. You don't need to fill in the other paths. | ||
+ | # Select debug and/or release configurations for your project. The debug configuration at least is recommended. | ||
+ | # Choose your wxWidgets build options. '''These must match the options used when you built wxWidgets!''' If you followed the directions above, select all three of the options under "wxWidgets Library Settings". '''If you are using wxPack:''' wxPack includes each version, so you may select whichever options you prefer. The other settings on this page are not related to the wxWidgets build options; you may use them or not as you prefer. If, for some reason, you want to use a debug wxWidgets build, select "Configure Advanced options" and then select "Use __WXDEBUG__ and Debug wxWidgets lib" on the next page. | ||
+ | # Select additional libraries if required. You should not need to select any of these for normal usage. | ||
+ | |||
+ | == Build and Run == | ||
+ | Select "Build and run" (F9) to, well, build and run. If all goes well, your wxWidgets basic program should appear. |
Revision as of 20:39, 15 September 2007
A beginner's quick reference for setting up wxWidgets with Code::Blocks in Windows
Important Requirements:
- Windows compiler - You need to have correctly installed the free MinGW/GCC compiler or one of Microsoft's compilers (the Express editions are free, but you must also install the Platform SDK). If using MinGW/GCC, you need at least the gcc-core, gcc-g++, binutils, w32api, and mingw32-make packages; also, ensure that the folder containing the compiler executables (typically C:\MinGW\bin) is in your Windows PATH environment variable.
- Nightly build of Code::Blocks - You need to have successfully installed and run [/index.php/board,20.0.html a recent nightly build of Code::Blocks].
Download wxWidgets
You can choose to download the wxWidgets source code and compile it yourself, or download the "wxPack", a precompiled version.
- The wxWidgets sources are a much smaller download, but you must also spend some time compiling them.
- wxPack is a much larger download, but you don't have to spend time compiling it or worry about build options.
wxWidgets Sources
The current recommended version of wxWidgets to use is 2.8.5. Click here to download the wxWidgets 2.8.5 sources for Windows (wxMSW-2.8.5.zip; 15.8 MB). You can check the wxWidgets download page to see if a newer stable version is available. It is highly recommended that you extract the sources to a path without spaces. You should choose a volume with at least 300 MB of free space.
wxPack
The current stable release of wxPack is v2.8.4.02, based on wxWidgets 2.8.4. Click here to download wxPack v2.8.4.02 (wxPack_v2.8.4.02.exe, 222.7 MB). It is highly recommended that you install wxPack in a path without spaces. You should choose a volume with at least 700 MB of free space for MSVC, or 2.2 GB of free space for MinGW/GCC.
Build wxWidgets
This step is unnecessary if you are using wxPack
- Open up a command prompt for building. If you are using MinGW/GCC, simply use the standard Windows command shell (open the Start menu, click "Run...", enter "cmd" and hit OK). If you are using MSVC, you should use the special command shell which sets up the correct environment variables for you. If you use a version of MSVC which required you to download the Platform SDK separately, ensure that whichever command environment you use includes the Platform SDK tools and paths as well as the standard compiler tools and paths.
- Change to the wxWidgets build directory (where <wxWidgets> is the path you extracted the sources to; typically C:\wxMSW-2.8.5):
cd <wxWidgets>\build\msw
- Execute the build command. The recommended command to use for MinGW/GCC is:
mingw32-make -f makefile.gcc BUILD=release SHARED=1 MONOLITHIC=1 UNICODE=1
- The recommended command to use for MSVC is:
nmake -f makefile.vc BUILD=release SHARED=1 MONOLITHIC=1 UNICODE=1
- This step will generally take a long time; faster PCs may expect 30-minute build times, and slower PCs can take as much as several hours.
- If using more recent versions of GCC, many warnings will occur during the build. This can slow the build process noticeably; you may want to redirect the warnings to a text file by appending "2>errlog.txt" to the build command, or supress them entirely by appending "2>nul".
wxWidgets build options explained
What do the BUILD, SHARED, MONOLITHIC, and UNICODE options mean?
- BUILD=release indicates that we want the faster and smaller release build of wxWidgets, as opposed to the heavyweight debug build (BUILD=debug). You can still debug your own programs that use the wxWidgets release build.
- SHARED=1 indicates that we want to use wxWidgets from a separate DLL instead of statically linking the wxWidgets code into every program. This saves time compiling, and saves space.
- MONOLITHIC=1 indicates that we want all of the wxWidgets code in a single library, rather than split up into separate component libraries. This merely makes the wxWidgets library easier to work with while developing.
- UNICODE=1 indicates that we want Unicode-compatible strings and language support in our programs. This should always be preferred except on pre-Win2k systems, where you must either install a separate Unicode library or build with UNICODE=0.
Why are these options critically important?
These options define the basic wxWidgets development environment you will be using. You must duplicate them exactly when running Code::Blocks' wxWidgets project wizard.
Create a wxWidgets project in Code::Blocks
- On the Code::Blocks Start Page, select "Create a new project"; alternatively, open the File menu, highlight "New" and select "Project..."
- Select "wxWidgets project"
- The first page is an introduction, which you can choose to skip in the future.
- Select which version of wxWidgets you will be using. If you followed the instructions above, you should select "wxWidgets 2.8.x".
- Set your project title and location.
- Enter author details if you wish (not required).
- Select options for automatic code and file generation.
- Select wxWidgets' location. It's highly recommended that you use a global variable for this: enter "$(#wx)" (without quotes). If you haven't already defined this global variable, the global variables dialog will appear; for the base path, select your wxWidgets installation location. You don't need to fill in the other paths.
- Select debug and/or release configurations for your project. The debug configuration at least is recommended.
- Choose your wxWidgets build options. These must match the options used when you built wxWidgets! If you followed the directions above, select all three of the options under "wxWidgets Library Settings". If you are using wxPack: wxPack includes each version, so you may select whichever options you prefer. The other settings on this page are not related to the wxWidgets build options; you may use them or not as you prefer. If, for some reason, you want to use a debug wxWidgets build, select "Configure Advanced options" and then select "Use __WXDEBUG__ and Debug wxWidgets lib" on the next page.
- Select additional libraries if required. You should not need to select any of these for normal usage.
Build and Run
Select "Build and run" (F9) to, well, build and run. If all goes well, your wxWidgets basic program should appear.