tutorials for compilation of wxWidgets on windows -- part 2A, -- wxWidgets and MinGW

  • From: "jaffar" <jaffar@xxxxxxxxxxxxx>
  • To: <programmingblind@xxxxxxxxxxxxx>
  • Date: Mon, 26 Nov 2007 09:29:49 +0800

Here comes part 2 of my tutorial for compiling and installing wxWidgets on
windows.  In this part, I will focus attention on a free gnu c++ compiler
for windows call MinGW which actually stands for Minimalist G++ compiler for
the WIN32 platform.  There are 2 methods of compiling wxWidgets on windows
using this free tool.  The first is to compile it in a unix-like environment
by invoking the unix hash or bash shell.  The second method is to compile it
strictly on the microsoft WIN32 environment.  For this tutorial, I am
assuming that you already have wxWidgets unzipped and saved to the directory
of your choice, So i'll go straight into the first method.
Now that you have wxWidgets saved onto your hard drive, The next thing
you'll need is the MinGW tool itself.  For this, go to
http://www.mingw.org/downloads.  There is a whole heap of packages there,
but for most of us who aren't so familiar with the MinGW toolkit, the
recommended and best approach would be for you to download the latest
MinGW.exe file.  This is a very small installer file that installs only the
necessary packages  you need to run MinGW, or which packages you choose via
a web install.  As of this writing, the latest installation is
MinGW-5.13.exe.  Install this to your hard drive.  Now, click it and choose
run.  After the usual license terms that you must agree to anyway to
continue the install, It will prompt you as to whether you want to install
the  earlier, the current or the development MinGw packages.  By default,
the selection is on current.  You can also choose a typical or a custom
install which will allow you to choose extra packages which you might need
for other tasks.  For this task, however, a typical install is sufficient.
You can also choose whether you want the installer to just download or to
download and install the packages for you.  Choose download and install.
When you are satisfied with your installation settings, click the install
button.  The installer will now download and install the necessary
components.  This process will take time, so have a coffee, or continue
reading up this tutorial while you wait.  Better yet, you can use this time
to search for a Unix-like command shell for windows called Msys from the
MinGW site or the Sourceforge site.
I believe that Msys has not gone through very many changes, so the latest
version is 1.0.10.
Installing Msys.
Installing Msys involves 2 processes.  The first is the typical windows
installer process where it will ask you to choose the installation directory
where you want msys to reside.  Leave it as the default.
Caution:  Do not install Msys, or any unix-like tools on windows into
directories which contains spaces.  Choosing to install Msys to C:\Program
Files\Msys, for example, is a bad idea.  The default is C:\Msys, so leave it
at that.
Caution ends.
Once you click finish, the installation of Msys will now be carried out as
if you were installing a program on dos.  Here, you'll have to choose Y for
yes, N for no, then hit the enter key.  This part of the process will
involve Msys creating what is called an AddStab file which will actually
tell msys how and where to find your MinGW installation.  The last question
it will ask during this process is exactly where you installed your MinGW
packages. Exactly is the operative word here, because it will save you the trouble of editting this file by hand, so Please go to the directory
where you installed MinGW, typically c:\MinGW.  Once you are sure of MinGW's
Installation path, type it into the command prompt.  Again remember that
your directory's path must not contain spaces.  After you have typed in the
installation path for MinGW, the installation will finish by prompting you
to press any key.  An AddStab file will now have been created.  This will
act like a batch file, setting up the MinGW-cum-Unix  environment whenever
you start Msys.
Setting the Environment path.
One thing to note when you set up the environment path for when you have
both MinGW and Msys installed is that Msys Must be set to point to the MinGW
path.  So go to your desktop, choose the "my computer" icon, then press the
right context menu key.  Arrow up once to properties, then press the enter
key and you'll be presented with a tab control which will allow you to
navigate it's various pages.  Right arrow to do so, until you hear advance.
Tab to the environment button, then hit the space bar.  Tab to the system
environment selection, then arrow down to path.  Tab to the i for edit
button, press the space bar and explore the line of softwares or tools whose
environment path windows has already created.  Go to the end of the line
with the ctrl+pagedown key combination, then type c:\Msys\bin;C:\MinGW\bin,
no semi-colon at the end.  Press Ok and you are done.  To test if it all is
in working order, go to your desktop and choose the Msys icon.  Click enter
and you'll be at a Unix command shell.  Type GCC -V.  If you see a GCC
followed by a version number, followed by a list of options, then you do
have a working installation of Msys and MinGW.
Building WxWidgets, the Unix way.
Ok. You should now be set up to build and install wxWidgets with MinGw and the Unix environment, but before we plunge into it, a non-technical, brief explanation of the Unix installation process is perhaps apt. You need to perform two steps to achieve a software installation on Unix. The first step is Configure. When you install a program on windows, some initial configuration steps are needed to ensure that your software runs in tandem with your system's own configurations. In windows, this step is almost always automated for you, so you need not involve yourself with a process that can sometimes be very cumbersome. In Unix though, this process is not always automated, and you'll need to know the steps in the configure process, particularly if you want to achieve an optimum build for your software. The second step in the installation process is a process called make. This is where the actual installation of your app takes place. You must pay particular attention to the configure step not only because this is the harder of the two, but also because it is this step in the installation process that will determine your build of wxWidgets.
Browse again to your wx directory. In the main directory tree, you'll find a file called configure without any extension. My recommendation is that you open up that file and study it carefully. Just add a .txt extension to it, then open it and take a look. In that file is where the build of your wxWidgets tool is determined. It contains many flags that you can disable or enable when you issue the configure command. Note that the flags are put into two distinct groups, one group begins with the --with- prifix, and another group begins with the --enable- prifix. Hear is a list of the important flags that you might want to set with a brief explanation of their context in your build of your wxWidget toolkit. Pay careful attention to the syntax of the flags as a missing dash or a misspelt word could render your configure process null and void, in which case you have to start over typing the configure command. This is no fun for those of you who are used to just answering yes or no to questions posed during windows installation processes, so be warned.
Start list of configure flags and their explanation:
--with-unicode: This will enable an Unicode build of the wxWidgets toolkit. Please note that if you are building apps for earlier versions of windows like win98, then don't enable this flag because your apps will not run on earlier windows versions then win2000. --with-odbc: This will add the ODBC library to your wxWidgets build. Note that the ODBC library is no longer supported and will be depricated in future versions of wxWidgets.
this will create an OpenGl library in your wxWidgets build. Note that OpenGl is an open source, free 3d engine that can be used to create multimedia, Music editting and games softwares. Visual c++ has native support for openGl.
--enable-debug:  Builds a debug version of your wxWidgets toolkit.
--enable-release:  Builds a release version of your wxWidgets toolkit.
--enable-threads:  Builds a threaded version of your wxWidgets toolkit.
--enable-rtti: enbles runtime info to be included with your wxWidget toolkit and your apps built with the wxWidgets toolkit. --disable-shared: This will prevent a build of your wxWidgets toolkit from utilizing a shared library or dll, but will enable the different GUIS to utilize it's own customized library or DLL. Do not use the --enable-shared flag unless you know what you are doing. --disable-universal: This will prevent your app from having the same look and feel should you decide to port your app to operating systems other than windows. Do not use the --enable-universal flag unless you know what you are doing.
End list.
There are many more flags you could call, so I suggest you study these flags carefully. But please be cautious because not all flags will be enabled or disabled because to some extent, your system's set up will determine whether some of the flags you include will successfully come into operation or not. Also, enabling or disabling some vital or non-vital flags will throw many exception handling errors because your toolkit simply couldn't operate with or without them. If you stick to the list, you should do fine. Now you are ready for your build. Go to your desktop and choose Msys from your desktop menu. Press enter. You will now be in the Msys hash Shell. Cd to your wx main directory tree like this. cd c:wx, or cd c:/wx. Do not apply the windows convention to cd to your wx directory. Remember you are now working in a Unix-like environment, and the use of the backslash key won't trigger anything but an error. now type, for example, and you must begin this command with a Dot followed by a forward slash, again Unix-like remember? ./configure --with-unicode --with-odbc --with-opengl --enable-access --enable-debug --enable-debug_gdb
--disable-shared all in a single line command.
When you are satisfied that all your required flags have been included in the command, press the enter key. Unfortunately, Msys does not verbosely announce the output of the configure process. With Window eyes, you could read the output by cursoring down the screen using the number 8 on the Number pad and with the numlock off. With jaws, try routing the jaws cursor. AT this stage, wxWidgets will be configured, meaning that the necessary files for creating the library files during the make process will be built. This includes .o and precompiled header files. A makefile will also be generated for the make process. Once the configure process is finished, you will see a series of statements, something like "Build wx with Unicode? yes". At this stage, you are now ready to install the wxWidgets toolkit. type Make Install. The make process will now be initialized. This process takes quite a while, so have a break. The process is finished when you see the wxWidgets license and word done on the screen. Just one more step. The make process will cause your wx directory to be large and cluttered with the .o files that you no longer need. To remove them, type rm and .o as the target. You will now be just left with the needed DLLS files in your /lib directory that you can link your apps against. The dll files of the Gcc versions of the wxWidgets toolkit can be rather large. To reduce their size, you can issue a strip command like this:
Strip -f somefile.dll
However, please note that stripping will remove any debug info in the files.
Congratulations, you now have a working GCC version of the wxWidgets toolkit. The native Windows build with gcc will follow in part 2 B. All questions and comments welcomed.
View the list's information and change your settings at http://www.freelists.org/list/programmingblind

Other related posts:

  • » tutorials for compilation of wxWidgets on windows -- part 2A, -- wxWidgets and MinGW