Difference between revisions of "Compiling wxWidgets 2.4.2 to develop Code::Blocks (MSW)"

From Code::Blocks
m
(This page needs to go bye-bye)
 
(4 intermediate revisions by 2 users not shown)
Line 1: Line 1:
[[Category:Installation]]
 
[[Category:Build Intructions]]
 
[[Category:Windows]]
 
 
[[Category:Outdated]]
 
[[Category:Outdated]]
 
+
[[Category:Deletion Requests]]
 
<div style="margin:0;  border:2px; padding: 2em 2em 2em 2em; background-color:#FFd6c0;">
 
<div style="margin:0;  border:2px; padding: 2em 2em 2em 2em; background-color:#FFd6c0;">
 
'''Obsolete:'''<br />
 
'''Obsolete:'''<br />

Latest revision as of 00:17, 29 November 2006

Obsolete:
Do not use these instructions for building Code::Blocks. It needs wxWidgets-2.6.x to compile. Please read Compiling wxWidgets 2.6.2 to develop Code::Blocks (MSW)

These are the instructions to compile wxWidgets so that you can compile Code::Blocks on your own.

NOTE: These instructions are MS Windows (TM) specific, but because we are using MinGW it should be possible to use these instructions with some modifications on other platforms.

Install MinGW

If you don't have the Code::Blocks+MinGW bundle, grab the latest MINGW stuff (including MSYS) from the MINGW site and install it under a directory you like. In this tutorial we're assumming you're installing MINGW under C:\MINGW.

If you DO have the Code::Blocks + MinGW bundle, or have already installed MINGW on your own, you can skip this section.

NOTE: The files are compressed in the tar.gz format. You need a third-party extraction utility to unzip them.

The files I (Rick) have installed are:

After you install, make sure you have the following directories under your path:

  • C:\MINGW\bin;
  • C:\MINGW\mingw32\bin;

(I'm assumming you installed under C:\MINGW)

Install the unix-like commands

The wxWidgets makefile requires some unix commands (like cp) to run correctly. To avoid this windows-linux compatibility problems, you have two options:

a) Download the extra.zip package, or

b) Setup MSYS.

About the extra.zip package

The extra.zip package contains some programs which mimic frequently-used commands in Linux.

To install, just download it and unzip it in your MINGW directory.

About MSYS

The MSYS package (NOT included in the Code::Blocks+MinGW bundle) allows you to run unix scripts with Mingw. Think of it as a "mini-linux emulator". When you run the executable installer, it will provide a link to msys.bat. If it doesn't appear in your desktop, search for it in your programs menu.

If you don't have the extra package, you must run the wxWidgets 2.4.2 compilation from inside MSYS. Drive C is found under /c/, drive D under /d/ and so on.

Download and Install the wxWidgets source code

The wxWidgets 2.4.2 distribution can be found at the wxWidgets site. (Note that there's also a winhelp file available). You can choose to install either the setup version or the plain zip version (which I find ridiculous, because the setup version is zipped too!).

If you use the plain zip version, make sure to unzip using the full path. Otherwise the directories won't be created correctly. On a second thought, you might like to use the setup version :P

I have my wxWidgets installed in C:\wxWindows-2.4.2 . Under MSYS, that should be /c/wxWindows-2.4.2 .

And now that you have all the ingredients, it's time to compile :)

Build wxWidgets

NOTE: We're assumming you installed under C:\wxWindows-2.4.2 .

Before anything, let me warn you: wxWidgets compilation is SLOW. And by SLOW I mean the time equivalent to one or two evolution cycles, like from Triasic to Jurasic, but doubled. So make sure there's a nice show on the TV, or you could invite a friend to play cards. OR you could start preparing the coffee :)

Now, open up your MSYS prompt, and change to the wxWidgets src/msw directory:

cd /c/wxWindows-2.4.2/src/msw

Then proceed to the build. But first, an important warning that will save you many headaches.


WARNING!
If due to a misconfiguration (like changing the version of your MINGW), your compilation fails, MAKE SURE you clean out the outputs directory with the following command:
mingw32-make -f makefile.g95 clean
(do it for wxwidgets, stc and xrc. I had weird linker errors and crashes because I didn't clean up the partial compilations).


And now that everything's clean, proceed to the build:

mingw32-make -f makefile.g95 FINAL=1 UNICODE=0 WXMAKINGDLL=1

If no "mingw32-make" is found, try this:

make -f makefile.g95 FINAL=1 UNICODE=0 WXMAKINGDLL=1

Is it compiling OK? Good! You can now enjoy your coffee :-)

Build the STC library

Still inside MSYS, type:

cd ../../contrib/src/stc

That should change the directory to /c/wxWindows-2.4.2/contrib/src/stc. Now type:

mingw32-make -f makefile.g95 FINAL=1 UNICODE=0 WXUSINGDLL=1

(NOTE: There are NO line breaks in the command, if you see them, they're shown for readability)

Build the XRC library

Still inside MSYS, type:

cd ../xrc

That should change the directory to /c/wxWindows-2.4.2/contrib/src/xrc. Now type:

mingw32-make -f makefile.g95 FINAL=1 UNICODE=0 WXUSINGDLL=1

And that's it! Now you only have to copy the lib and include directories so your MINGW installation can find them.

Copy the files to your mingw directory or set up the paths

This section provides you with two alternatives: The easy one, and the hard one. The easy one consists of just copying the files to your MINGW directory. The hard one consists of setting up the paths in codeblocks.

Option 1: Copying the wxWidgets files over your MINGW installation

NOTE: The following instructions will overwrite part of your MINGW installation. If you're planning to build unicode applications, or use another version of wxWidgets, DO NOT, repeat, DO NOT follow these! Instead you'll have to set up the paths manually.

So, here's how to copy the files. I (Rick) guarantee this option works, since it's the one I used.

Close your MSYS window, and now open your windows explorer (NOT internet explorer, but Windows explorer. To open it, just press "(Windows key)+E"

It's recommended to open TWO explorer windows: One for your wxWidgets directory (which we'll change to copy different files), and another to

Copying the header files

In the location bar, select the following path:

C:\wxWindows-2.4.2\include

Select all the files AND DIRECTORIES and copy. Change to the directory "include" under your MINGW main directory, and paste.

Now change again the directory to:

C:\wxWindows-2.4.2\contrib\include

Copy all files and directories, and paste them to your MINGW include directory.

Copying the library files

Change the explorer directory to:

C:\wxWindows-2.4.2\lib

And select all the files. Copy and Paste under your MINGW "lib" directory.

Copying the setup.h file

This one's very important! Normally people know to copy the headers and libs, but miss this step. If you miss it, you'll get LOTS of compilation errors.

Change the explorer directory to:

C:\wxWindows-2.4.2\lib

There is a "mswdll" directory there. Under it, there's a "wx" subdirectory, too. Inside it there's a "setup.h".

Copy it, and paste under your MINGW include/wx directory.

(END of option 1)

Option 2: Setting up the paths manually

These instructions are to be followed by those who plan to use the 2.6 version of wxWidgets, or want to build their own version (i.e. with unicode support). Since you can't use both 2.4.2 and 2.6 libraries at the same time, you have to keep them in separate directories.

Open the CodeBlocks.cbp, to be found in your local Code::Blocks source directory (for example "C:\codeblocks\src"). Open up the build options, change the tab to "Directories" and add the following, replacing <WXW> with your WxWindows directory, for example "C:\wxWindows-2.4.2" (without the quotes):

Compiler

  • <WXW>\include
  • <WXW>\contrib\include
  • <WXW>\lib\mswdll

Linker

  • <WXW>\lib

Resource compiler

  • <WXW>\include

And that's it. Now you're ready to compile Code::Blocks!

Post compilation steps (before running C::B)

When compilation process is finished, simply run the update.bat script. It will ensure that all resource files (that C::B uses) are in the right place and up to date.

Note: This step requires appropriate zip command, which you likely have already set up and working. However, in case you have not, you should find something usable here.

Common compilation problems

symbol `_D' is already defined

Your MinGW installation is probably outdated (dev-cpp user perhaps?). Make sure you're using GCC 3.4.2 or later.

undefined reference to `_imp__wxTheApp' (& others)

If you encounter this one, try changing your linker options.

  1. MENU: Settings->configure plugins->compiler->other->advanced options (for me it was Settings->Compiler->Other->Advance)
  2. Choose: "Link object files to executable".
  3. It should be: $linker -o $exe_output $libdirs $link_objects $libs $link_options

Worked for me. Original credits to rickg22 (see [/index.php?topic=137.msg553 this thread]) - rykon