Building wxWidgets under MinGW/MSYS for use with Eclipse

Lars Uffmann aral at nurfuerspam.de
Wed Apr 30 05:55:21 PDT 2008



Hi everyone!

First off, I guess I am still a newbie at making/building stuff under 
Linux and Linux-like environments, so forgive me if I am missing 
anything obvious.

I successfully managed to get an Eclipse CDT environment running on my 
system with cygwin and wxWidgets in the past, so that my wx libraries 
could be included with the simple script call to `wxconfig --cxxflags` 
for the compiler and `wx-config --libs` for the linker.

Now I need to make a guide for an offline installation (cygwin really is 
a little annoying about that) and managed to set up MSYS (with 
predownloaded files) and Eclipse on a fresh winXP SP2 system, to the 
point where I can compile stuff in Eclipse, and I built wxWidgets so 
that I could make (using mingw32-make) the minimal sample - executable 
runs fine.

However, when I try to call wx-config (wxWidgets main directory only has 
wx-config.in script) with the parameter --cxxflags, I get the following 
error message:

   Warning: No config found to match: wx-config.in --cxxflags
            in @libdir@/wx/config
   If you require this configuration, please install the desired
   library build.  If this is part of an automated configuration
   test and no other errors occur, you may safely ignore it.
   You may use wx-config --list to see all configs available in
   the default prefix.

However, using
sh wx-config --list
I get nearly the same message:

     Default config is 
@TOOLKIT_DIR@@TOOLKIT_VERSION@@WIDGET_SET at -@WX_CHARTYPE at -@WX_DEBUGTYPE at -static-@WX_RELEASE@@WX_FLAVOUR@

   No config found to match: wx-config.in --list
   in @libdir@/wx/config

   Please install the desired library build, or specify a different
   prefix where it may be found.  If the library is not installed
   you may call its wx-config directly by specifying its full path.


Does this mean that I have not used mingw32-make correctly, and should 
have supplied other options to actually make the proper wxWidgets 
configuration? When the minimal sample worked fine, I was assuming I did 
things correctly, but I am not so sure now.

I have attached a checklist of exactly how I installed the system, in 
case you have any questions that might be answered by that.

My main concern is: a) I'd like NOT to have to use and distribute 
cygwin1.dll with my executables (the less dlls, the better), and b) I'd 
like to be able to include wx-widgets libraries like before, with the 
wx-config call, instead of copypasting the looooong include directive 
with all the libraries in each new wxwidgets project.

Thank you for any help!

    Lars


Checklist of installation (unfinished atm):
------------------------------

Installation Guide for setting up Eclipse CDT development environment
Version 2008-04-23
compiled by Lars Uffmann (lars.uffmann at dlr.de)
=================================================


1. MinGW installation
========================
- execute MinGW\MinGW-5.1.3.exe

When prompted whether to "Install or just download files?"
- choose "Download and install" (nothing will be downloaded in this 
procedure)
- select "Next"

On the license agreement
- select "I Agree"

When prompted "Which MinGW package do you wish to install?"
- choose "Current"
- select "Next"

When prompted to "Choose Components"
- select the type of install: "Custom"
- select the optional components:
  - g++ compiler
  - MinGW Make
- select "Next"

- leave "Destination Folder" at default value ("C:\MinGW")
- select "Next"

- leave Start Menu folder at default (or change to your liking)
- select "Next"

- select "Install"

Wait for completion, then
- select "Next"
- select "Finish"
========================


2. Setting MinGW Environment Variables
==================================
- go to Start -> Settings -> Control Panel -> System
- select the "Advanced" page
- select "Environment Variables"
- In the bottom list, labeled "System variables", in the "Variable" 
column, find and select the entry "Path"
- below that list, select "Edit"
- in the field "Variable value", append (CAUTION: DO NOT OVERWRITE!) 
this to the existing text:
   ";C:\MinGW\bin"
   (without the quotes)
- select "OK"
- select "OK" (again)
- select "OK" (third time)

- execute MinGWPathEntries.reg (by doubleclicking)
When asked "Are you sure you want to add the information in <current 
dir>\MinGWPathEntries.reg to the registry?"
- select "Yes"
When informed the information has been successfully added to the Registry
- select "OK"
==================================


3. MSYS Installation
=======================
- execute MSYS-1.0.11-2004.04.30-1.exe
- select "Yes"
- select "Next"

On the license agreement
- select "Yes"
- select "Next"

When asked to "Select Destination Directory", leave it at default value 
("C:\msys\1.0")
- select "Next"

When asked "Which components should be installed?", leave selection as 
is (only 1 installation option anyways, i386)
- select "Next"

When asked to choose a Start Menu Folder, leave it at default (or change 
to your liking)
- select "Next"

On the "Ready to Install" window
- select "Install"

This will now pop up a DOS window asking you:
--- DOS Window ---
"This is a post install process ..."
- just type "y" (without the quotes) there and confirm with Enter

When asked "Do you have MinGW installed?"
- type "y" (right - no quotes again ;) and confirm with Enter

When asked "Where is your MinGW installation?"
- type "c:/mingw" (you guessed it - no quotes) and confirm with Enter

Wait a moment, then when asked to "Press any key to continue . . ."
- press Enter again

DOS window will close now.
--- End of DOS Window ---

On the setup window
- deselect the checkboxes for "Welcome to MSYS" and "README"
- select "Finish"
=======================


4. Setting MSYS Environment Variable
==================================
- go to Start -> Settings -> Control Panel -> System
- select the "Advanced" page
- select "Environment Variables"
- In the bottom list, labeled "System variables", in the "Variable" 
column, find and select the entry "Path"
- below that list, select "Edit"
- in the field "Variable value", append (CAUTION: DO NOT OVERWRITE!) 
this to the existing text:
   ";C:\msys\1.0\bin"
   (without the quotes)
- select "OK"
- select "OK" (again)
- select "OK" (third time)
- reboot your machine so that environment variable changes (from 2. & 
4.) take effect
==================================


5. Java Runtime Environment Installation
===========================================
Note: You may already have a Java Runtime Environment installed on your 
system.
In this case it may or may not be necessary to install a newer version.

- execute jre-6u6-windows-i586-p.exe
On the "Welcome to Java"-window
- select "Accept >"
This will start the installation process. When it is done
- select "Finish"
===========================================


6. Installing Eclipse CDT
============================
Create a program folder where you want to put the Eclipse application, e.g.
- create the folder "c:\eclipse"
- copy the contents of "eclipse-cpp-europa-winter-win32\" into the 
folder you created

Create a shortcut for Eclipse on your desktop:
- right click "eclipse.exe" in the new folder
- select "Copy"
- right click on unused space of your desktop
- select "Paste Shortcut"
- right click the newly created shortcut
- select "Rename"
- name it "Eclipse CDT"
- double-click the shortcut to launch Eclipse for the first time

When asked to "Select a workspace" (this is where all your program 
sources and project files will be stored)
- choose a folder that suits you
   (I recommend "D:\Eclipse Workspace" - or any other drive that is not 
the system drive)
- check "Use this as the default and do not ask again"
- select "OK"

When Eclipse shows the Welcome-Screen
- close tab by clicking the X to the right of the title "Welcome"


7. Verification that everything is working
=============================================
In the Eclipse Main Menu
- select "File" -> "New" -> "C++ Project"

In the "C++ Project" window
- type "configTest" as Project name (note how the grayed-out default 
location updates as you type)
- select "Finish"

In the Project Explorer on the left, you will now see the new project 
named "configTest"
- right click the project name, select "New" -> "Source Folder"

In the "New Source Folder" window
- type "src" as Folder name
- select "Finish"

The new folder "src" now appears in the project explorer
- right click this folder, select "New" -> "Source File"

In the "New Source File" window
- type "configTest.cpp" as Source File
- select "Finish"

This will open a text editor to the right of the Project Explorer, and 
the text editor
window should be labeled "configTest.cpp". In this window
- enter the following code (make sure to add a newline after the last 
line of code)
/* ********* */
#include <iostream>

using namespace std;

int main()
{
	int i;
	
	for (i=0; i < 15; i++)
		cout << i << " ";
	
	cout << "done..." << endl;
	
	return 0;
}

/* ********* */

- from the Eclipse main menu, select "Project" -> "Build Automatically" 
to disable it
- from the Eclipse main menu, select "Project" -> "Build Project"
If everything is working fine, this should result in the following text 
in the Console window
below your text editor window:

    **** Build of configuration Debug for project configTest ****

    **** Internal Builder is used for build               ****
    g++ -O0 -g3 -Wall -c -fmessage-length=0 -osrc\configTest.o 
..\src\configTest.cpp
    g++ -oconfigTest.exe src\configTest.o
    Build complete for project configTest
    Time consumed: 453  ms.

Obviously, the "Time consumed" value may vary, depending on your system 
speed.

- from the Eclipse main menu, select "Run" -> "Run As" -> "1 Local C/C++ 
Application"
This should result in the following output in the console window:
    0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 done...
=============================================


Congratulations, you have successfully installed Eclipse CDT and can now 
use it for development
of C/C++ applications that will port easily to other operating systems.


Some more things:
====================
- The default Build configuration includes some debugging settings, this 
means
   * your executable will be located in the Eclipse workspace subfolder
     "configTest\Debug\"
   * the executable configTest.exe will be considerably larger in size 
than a release configuration
     would be
========
You can strip the debug information from the file by
- opening a DOS prompt (- select "Start" -> "Run", - type "cmd", - 
select "OK")
- typing
strip "D:\Eclipse Workspace\configTest\Debug\configTest.exe" 
(Attention: this time you need the quotes)
- confirming the command with Enter
- exit the DOS prompt by typing
exit
- confirm with Enter
========

If you want to change the Build configuration for your project to 
release configuration
- select the desired project (configTest) in the Project Explorer
- from the Eclipse main menu, select "Project" -> "Properties"
   (alternatively, just hold the  ALT-key down and hit Enter)

In the "Properties for configTest" window
- select "C/C++ Build" in the list on the left

In the "C/C++ Build" configuration that is displayed on the right side
- select "Manage configurations"

In the "Manage configurations..." window
- choose "Release"
- select "Set Active"
- select "OK"
- select "OK" again to close Project Properties
(Alternatively you can change to Build Configurations by opening the 
dropdown-menu next to the
Hammer-icon in the Eclipse menu bar and selecting the desired 
configuration - this will also
  start a build right away)

- from the Eclipse main menu, select "Project" -> "Build Project"
Your release executable will now be located in the Eclipse workspace 
subfolder
     "configTest\Release\"
Note: depending on the Release build configuration settings, this 
executable may still
shrink if you use the strip command on it.


8. Installing wxWidgets
==========================
- close Eclipse (if still open)
- open wxWidgets-2.8.7.zip
- move the contained folder wxWidgets-2.8.7 to drive C: (so that it 
becomes C:\wxWidgets-2.8.7)
- open Windows Explorer, go to "C:\msys\1.0\bin"
- rename "sh.exe" to "_sh.exe" (this will otherwise interfere with the 
installation process)
- open a DOS prompt (- select "Start" -> "Run", - type "cmd", - select "OK")
- type
cd \wxWidgets-2.8.7\build\msw
- confirm with Enter
- type
mingw32-make -f makefile.gcc
- confirm with Enter

The wxWidgets libraries will now be built, this will take quite a while, 
depending on machine
  speed, in the order of 15 minutes.


More information about the wx-users mailing list