Re: Tutorials for compilation of wxWidgets on Microsoft windows

  • From: "Octavian Rasnita" <orasnita@xxxxxxxxx>
  • To: <programmingblind@xxxxxxxxxxxxx>
  • Date: Tue, 20 Nov 2007 15:11:15 +0200

Thank you for this tutorial Jaffar.

Octavian

----- Original Message ----- From: "jaffar" <jaffar@xxxxxxxxxxxxx>
To: <programmingblind@xxxxxxxxxxxxx>
Sent: Tuesday, November 20, 2007 12:02 PM
Subject: Tutorials for compilation of wxWidgets on Microsoft windows


Hi all. As an unbiased approach towards writing these tutorials on compiling wxWidgets on windows, I thought I'll write them up on my experiences based on the 3 most used C/c++ compilers, Vc++, BCC and Gcc using the MinGW environment. This is also an intro for those of you who might be interested in exploring the possibilities of venturing into this great open source programming resource. Please note that my emphasis here will be on WxWidgets itself, Not on it's derivatives such as wxPython or wxPerl, but the main wxWidgets which is the C++ framework or toolkit. Also note that i am not going to instruct you in it's use as the teaching of it is well documented on it's website, but concentrate solely on it's build and compilation, particularly from the command line as i think personally that this would be the shortest and most time effective approach.

Introduction.
What is wxWidgets? Like MFC, it is a c++ framework or toolkit which provides you with wrappers, classes and libraries to build a Windows program with c++. Unlike MFC though, it is free, open source and cross platform, meaning that you could program, for example, Windows GUIS on unix, then port it to Microsoft Windows and vice versa, then give it a native look and feel. For more info on WXWidgets, please refer to:
http://www.wxwidgets.org
For instructions on it's usage, please go to
www.wxwidgets.org/wiki
from where you can get a wealth of documentation and reference these tutorials as well. Please note the the use of wxWidgets is governed by the wxWindows license which allows you to create both open source and commercial apps with wxWidgets without any limitation as long as acknowledgement of the fact that the app was built with wxWidgets is forthcoming from you the vendor. As of this writing, the latest stable version of wxWidgets that is recommended for download and use is version2.8.6. However, if you are not of the faint hearted and would like to try and test out unstable and buggy code, but endowed with the latest features, you could try getting the nightly snapshot from it's cvs branch. I wouldn't recommend this cause of action to any novice though, and I wouldn't want to be responsible for ensuing headaches or system aches as the case might be, so exercise caution and really make sure you know what you're doing before pursuing this cause of action. WxWidgets comes in many flavors as would be expected out of it's cross platform nature. there is wxWidgets for Motif, WxWidgets for x11, WxWidgets for os2 and I could go on. But what we are primarily interested in, in this scenario is WxWidgets.exe which is a typical windows executable binary, and WXAll which has versions of all the platforms it covers in one zip or bz2 file. To obtain either of this, go to
http://www.wxwidgets.org/downloads
and follow either the links which say sourceforge or UK Mirror. I highly recommend the UK mirror as it is much faster and you don't have to wait for page download time which could be very irksome in the case of the SourceForge website. You could also follow the direct version link, but that will take you to Sourceforge. In any case, choose which ever binary suits your needs. If you are more comfortable with the standard windows installation procedure, choose the wxWidgets-2.8.6.exe which would install wxWidgets like all other typical windows installers to your hard drive. Note that it will also install all associated help files and appropiate documentation along with the source. Please take note however that the installation doesn't set any environment variables for you, which you must do yourself, and i will deal with that a little later. If you choose to download the WXAll zip source files and install and build it yourself, then please pay close attention as we have really come to the meat of the subject. Even for those of you who downloaded the .exe binary, pleas do not skip the following part of the tutorial as knowledge on building your sample and demo apps found in the distribution file is heavily reliant on what you've learnt from hereon.
WXWidgets building tools.
Along with the zipped source distribution of wxWidgets, You'll need one of the following tools to build and install wxWidgets onto your hard drive. However, if you want different variants of the windows flavored wxWidgets on your pc, there is nothing to stop you from obtaining all of the tools mentioned here. 1. VCExpress accompanied by the windows platform SDk which you can obtain freely from the Microsoft website. (note: If you have any other version of the MSVC other than the VCExpress, then you need not worry about the Platform SDK as these are fully provided with it's own C++ Compilation tools). 2. The older versions of the borland ide and compiler which you can obtain from the Borland site (Note that the download sites for these are rather obscure and the best way to pinpoint their location is by doing a search on google or your favorite search engine).
3.  MinGW which you can obtain from the MinGW site,
http://www.mingw.org
With MinGW, you can choose to compile in a unix-like environment by obtaining the following additional tools: i. MSYS, a unix style shell command utility which you can locate at the MinGW site.
ii.  Cygwin,
http://www.cygwin.org
which actually comes with it's own gcc compilers.
If you compiled and build wxWidgets with Microsoft's Visual Studio 6.0, 7.0, 7.1 or 8.0, You'll get a VC build of wxWidgets. If you install and build it with borland and/or MinGW on the other hand, you'll get a BCC and a GCC build respectively. Caution: Visual Studio 7.0 has been found to be very buggy when used to build wxWidgets. I wouldn't recommend this particular version but 6.0, 7.1 or 8.0 instead. The older versions of the GCC compiler has also been shown not to have work well. My recommendation is for you to download the most current version.

Going the VC way.
Having obtained wxWidgets and your building tools of choice, it is now time for us to start building your WxWidgets sources. Here are the detailed steps. 1. Unzip your source distribution of wxWidgets to a convenient location on your hard drive. I would typically unzip mine to c:\wxWidgets-2.8.6. In all cases, the path folder has already been set for you, and it is just a matter of choosing the drive that is most convenient to you. I have also deleted the unnecessary version number found in the path, and since it still works, c:\wx would save you lots of memory loss time. 2. Having unzipped your files into the set folder, the folder tree of your wx distribution would now typically look like this:
main folder: c:\wx
subfolders:
art,
build,
contrib,
demos,
distrib,
docs,
include,
lib,
locale,
misc,
samples,
src
and a few more which are of no concern to us at this stage.
The most important subdirectory you have to concern yourself with for now is the build directory. If you browse it, you will find the necessary folders which will influence your build of wxWidgets. Concentrate on the msw folder for now. 3. Browse the msw folder. you will find a file called makefile.vc. This is typically a makefile that you can configure to achieve a VC++ build of wxWidgets which is to your liking. Open up the file by changing it's extension to, for example, makefile.vc.txt. You might get a message telling you that by changing a file extension, you will render it unusable or some such. Ignore it. You can now open the file with notepad and access it's contents. Change the configurable flags in the file to suit your needs. For example, set unicode build of wxWidgets to 1 if you want a unicode build, 0 for ascii. Set the ODBC library flag to 1 if you want to include the ODBC library in your build, set it to 0 for no. Just pay attention to any of the default settings and tweak as and when you need. Also take note that a dynamic build will produce DLLS and a static build will result in Lib or library files which you would need to link to your apps. Also take note of the debug or release versions of the wxWidgets that is possible for you to build. Once you are satisfied with your configuration, save the file and close. don't forget to rename the file back to makefile.vc. If you want to refine your vc build. you can do so by opening the wx_setup.h file found in the include folder. Follow the same steps as above to access and configure that file. 4.Set up the environment path. Although there are some tools to help with this, I have found that setting up the environment path by hand is the most safest and surest way of doing it. Here are the steps. I. Set your WXWIN path by first going to your my computer selection on your desktop. Press your right context menu key to bring up the various submenu selections. Arrow up once to properties where you'll land on the general tab of the properties pages. Arrow right to advanced, then tab until you hear the tab button being announced. Press the space bar to get into the environment page. You will land on the user environment list, tab again to new and press the space bar. the first edit field you'll encounter is the user variable. type in "WXWIN" without the quotation marks. Tab once more, now to the value edit field, type in the location of your wx folder, in my case, c:\wx. Press ok. II. Now tab to the system variable list. Choose path with the down arrow key, then tab to the I for edit button. Press the space bar and you'll be presented with an edit field with a line of system variable paths separated by semicolons. Check if your Visual studio and your platform SDK bin directories are there. This is especially important if you are building with VCExpress. If not, type them at the end of the list like this. First put a semicolon after your last entry, then add the path to the mentioned bin directories, typically ;C:\Program Files\Microsoft Platform SDK r2\Bin. Please note that if you are using VCExpress, then the sdk bin directory must come after the VCExpress directory. Press ok 3 times. The paths are now set.
Building
After all the priliminary ground work, it is now time to get building. Open the command prompt. CD to the folder where vcvars32.bat (if you are using VC++8.0 other than the express version), is located, and setenv.cmd (if you are using VC++Express with the platform SDK), is located. Typically, these would be %program files\microsoft Platform SDK r2% for setenv.cmd, %program files\microsoft visual studio8\tools\bin for vcvars32.bat. These will set up the appropriate environments to build your wxWidgets distribution. You could copy both files to your C:\ drive if it helps, which i personally have done. If everything went well, if all instructions were observed, you can now have a working version of wxWidgets by issuing the following commands. CD c:\ Vcvars32.bat (if you copied this file there.) A message will tell you in essence that the microsoft visual studio tools environment has been set. now cd to c:\wx\build\msw. When the prompt confirms your presence in there, type nmake /f makefile.vc build=optimise. Your build will now begin. There will be lots of output which you can ignore, unless the debugger stops midway with some fatal error warnings. But if you have followed the instructions above, you'll find that your source will compile and build fine. The same will occur if you used setenv.cmd, except that this time, it will set the platform SDK environment. To test if your build works propperly, CD to the sample directory like this: cd c:\wx\samples\access, for example, then issue the makefile command. If it builds correctly, then congratulations, you have a working wxWidgets distribution. If you have any questions, feell free to ask. The borland and the MinGW build tutorials will follow in the next 2 to 3 days, depending on my work schedule. All thoughts on this little tutorial are welcomed. Cheers!

__________
View the list's information and change your settings at //www.freelists.org/list/programmingblind


__________
View the list's information and change your settings at //www.freelists.org/list/programmingblind

Other related posts: