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

From Code::Blocks
m (Enhanced warning paragraph.)
 
(53 intermediate revisions by 15 users not shown)
Line 1: Line 1:
These are the instructions to compile wxWidgets do you can compile Code::Blocks on your own.
+
These are the instructions for compiling wxWidgets for use with Code::Blocks. They are primarily intended in preparation for compiling Code::Blocks itself but (hopefully) may also help installing wxWidgets for general development using that framework.
  
'''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.
+
Although these instructions are targeted at the Windows operating system, it should be possible to apply them with slight adjustments to other platforms, since we make use of MinGW.
  
== Install MinGW ==
+
==Warning==
If you don't have the Code::Blocks + MinGW bundle, grab the latest MinGW stuff from the [http://www.mingw.org/download.shtml#hdr2 MinGW site] and install it under a directory you like.
+
<div style="margin:0;  border:2px; padding: 2em 2em 2em 2em; background-color:#FFd6c0;">
'''NOTE:''' In these instroctions we're calling the MinGW directory <MINGW>, so you have to replace that with you're own directory.
+
From November 2007 onwards you need wxWidgets 2.8.6 to develop Code::Blocks. See: [[Compiling wxWidgets 2.8.6 to develop Code::Blocks (MSW)]]
 +
</div>
  
'''If you DO have the Code::Blocks + MinGW bundle, or have already installed MINGW on your own, you can skip this section.'''
+
== Installing MinGW ==
 +
'''If you have installed the Code::Blocks and MinGW bundle, or 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. (like 7-zip)
+
Grab the latest MinGW files from the [http://www.mingw.org/download.shtml MinGW download site] and install them into a directory of your choice.
 +
 
 +
'''NOTE:''' In these instructions we call the MinGW directory ''<MINGW>'', therefore you have to replace it with your corresponding directory.
 +
 
 +
'''NOTE:''' The files are compressed tarballs. You may need a third-party extraction utility like [http://www.7-zip.org/ 7-Zip] in order to extract them.
  
 
You need at least the following files:
 
You need at least the following files:
Line 19: Line 25:
 
* [http://prdownloads.sf.net/mingw/binutils-2.15.91-20040904-1.tar.gz?download binutils-2.15.91-20040904-1.tar.gz]
 
* [http://prdownloads.sf.net/mingw/binutils-2.15.91-20040904-1.tar.gz?download binutils-2.15.91-20040904-1.tar.gz]
 
* [http://prdownloads.sf.net/mingw/mingw32-make-3.80.0-3.exe?download mingw32-make-3.80.0-3.exe]
 
* [http://prdownloads.sf.net/mingw/mingw32-make-3.80.0-3.exe?download mingw32-make-3.80.0-3.exe]
* [http://prdownloads.sf.net/mingw/gdb-5.2.1-1.exe?download gdb-5.2.1-1.exe]
+
* [http://prdownloads.sourceforge.net/mingw/gdb-6.3-2.exe?download?download gdb-6.3-2.exe] (GDB is not mandatory, but useful for debugging purposes)
GDB is not really needed, but could be usefull for debugging.
 
  
After you install, make sure you have the following directories under your path:
+
After successful installation of the above, make sure you have the following directories included in your PATH environment variable:
 
* <MINGW>\bin;
 
* <MINGW>\bin;
 
* <MINGW>\mingw32\bin;
 
* <MINGW>\mingw32\bin;
  
== Download and Install the wxWidgets source code ==
+
(You can add them by right-clicking the ''My Computer'' icon on your desktop and selecting ''Properties''. Then select the ''Advanced'' tab and choose ''Environment Variables''.)
The wxWidgets 2.6.1 distribution can be found at the [http://www.wxwidgets.org/dl_msw2.htm#stable wxWidgets website]. (Note that ther e is also a winhelp file available.) You can get choose between an installer and a zip file. You can just get the zip file because the installer is also a zipped version.
+
 
 +
== Installing the wxWidgets source code ==
 +
The wxWidgets 2.6.2 distribution can be found at the [http://www.wxwidgets.org/dl_msw2.htm#stable wxWidgets download site]. (Note that there is also a winhelp file available.) You can choose between an installer and a zip file. You can just get the zip file because the installer is also a zipped version.
  
 
If you use the plain zip version, make sure to unzip using the full path. Otherwise the directories won't be created correctly.
 
If you use the plain zip version, make sure to unzip using the full path. Otherwise the directories won't be created correctly.
  
'''NOTE:''' In the rest of these instructions we are calling the wxWidgets directory <WXWIN> you have to change it to your own directory. (e.g. "c:\wxWidgets-2.6.1")
+
'''NOTE:''' For the remainder of these instructions we call the wxWidgets directory ''<WXWIN>''. You have to change it to your corresponding directory (e.g. "c:\wxWidgets-2.6.2").
  
'''NOTE:''' you do not need MSYS. Furthermore, you cannot have MSYS in your path, or the wxWidgets compilation will fail. Thus if you have MSYS installed, ensure that <MSYS>\bin '''is not''' in your path before compiling wxWidgets. wxWidgets must be compiled from a "regular" command line (cmd.exe), not from a unix-like shell. BTW, The same problem would probably arise as well if cygwin is in the path.
+
'''NOTE:''' You do not need MSYS. Furthermore, you cannot have MSYS in your path, or the wxWidgets compilation will fail. Thus, if you have MSYS installed, ensure that ''<MSYS>\bin'' '''is not''' in your path before compiling wxWidgets. wxWidgets must be compiled from a "regular" command line (like cmd.exe), not from a Unix-like shell. The same problem could arise if Cygwin is in the path.
  
== Check make version ==
+
== Checking make version ==
If you didn't install MingW yourself you have to make sure you have the right version of make. Open the command prompt and type:
+
If you didn't install MinGW yourself you have to ensure you are using a recent enough version of the make utility. Open a command prompt and type:
 
  <tt>mingw32-make -v</tt>
 
  <tt>mingw32-make -v</tt>
If the version is 3.80 or greater it is allright to go on, else you have to install the new make.
+
The version should read 3.80 or greater, else you need to install a newer version.
  
 
== Building wxWidgets ==
 
== Building wxWidgets ==
 
Now it is time to compile wxWidgets, open the command promt and change to the wxWidgets directory:
 
Now it is time to compile wxWidgets, open the command promt and change to the wxWidgets directory:
  <tt>cd <WXWIN>\build\msw</tt><BR>
+
  <tt>cd <WXWIN>\build\msw</tt>
'''NOTE: The following directions do not work with msys, or other forms of Unix on windows.'''<BR><BR>
 
Now we are on the right place we are first going to clean up the source:
 
<tt>mingw32-make -f makefile.gcc USE_XRC=1 SHARED=1 MONOLITHIC=1 BUILD=release UNICODE=0 clean </tt>
 
'''NOTE:''' make sure you use the same options to clean that you use for the build step below.  the clean target uses these environment variables and only cleans that version of the generated object and library files (so it will actually not clean the intended files if these variables are not present) <br>
 
'''NOTE:''' if you still have problems with compiling after cleaning, you may want to remove the directory in the build\msw directory. (it contains object files...)
 
When everything is clean we can compile wxWidgets:
 
<tt>mingw32-make -f makefile.gcc USE_XRC=1 SHARED=1 MONOLITHIC=1 BUILD=release UNICODE=0 VENDOR=cb</tt>
 
'''NOTE:''' these options are the official Code::Blocks options. When you want another version of wxWidgets (unicode or debug) you have to make sure you build a MONOLITHIC version. (One big dll)
 
Now you can get a cup of coffee, or do something else, because this could take a long time.
 
 
 
== Build the STC library (Not needed for CVS HEAD version) ==
 
If you closed the command promt, you have to open it again.
 
We are going to the STC directory
 
<tt>cd ..\..\contrib\build\stc</tt>
 
We clean the source:
 
<tt>mingw32-make -f makefile.gcc USE_XRC=1 SHARED=1 MONOLITHIC=1 BUILD=release UNICODE=0 clean</tt>
 
And we going to compile it. Make sure you have the same build options as before.
 
<tt>mingw32-make -f makefile.gcc USE_XRC=1 SHARED=1 MONOLITHIC=1 BUILD=release UNICODE=0 VENDOR=cb</tt>
 
So now everything is compiled for using codeblocks.
 
 
 
== Copy libraries ==
 
When compilation is finished it is usefull to copy the libs to another directory. By doing this you can make several builds (e.g. debug and release).
 
* So first we create a directory this could be done in <WXWIN>\lib.
 
* Then we go to the directory <WXWIN>\lib\gcc_dll (could called diffrent when you changed the build options)
 
* Now we move all the files (.a .dll) and the directory (msw) to the directory of your choice. (for me it is <WXWIN>\lib\codeblocks)
 
'''NOTE:''' Make sure you everything is removed from the directory <WXWIN>\lib\gcc_dll else you can get trouble when compiling another version.
 
 
 
== Setting up paths ==
 
Everything is done now, and we can start compiling Code::Blocks, couldn't we? No! First we have to setup the paths.
 
Open the codeblocks project (CodeBlocks-wx2.6.0.cbp) and go to the Build options.
 
From there you have to go to the tab Directories and Compiler. Here you have to add the following paths (Remember to replace <WXWIN>)
 
* <WXWIN>\lib\codeblocks\msw
 
* <WXWIN>\include
 
* <WXWIN>\contrib\include
 
The first path is used to find the right setup.h for the build you are using. The other two are for the normal include files.
 
 
 
Now go to the Linker tab and add the following path:
 
* <WXWIN>\lib\codeblocks
 
'''NOTE:''' You have to replace this with the directory of your own choice in the previous section!
 
  
Finally, go to the resource tab and add the following path (Remember to replace <WXWIN>)
+
'''NOTE: The following instructions do not work with MSYS, or other forms of Unix on Windows.'''
* <WXWIN>\include
 
  
Now you are finished with the configuration and you can hit the compile button (CTRL-F9). Be aware that Code::Blocks is not officially  support wxWidgets 2.6.1 so it is possible that new files are not yet in the project. You have to do this by your self.
+
Now the first thing to do is to clean up the source:
 +
mingw32-make -f makefile.gcc MONOLITHIC=1 SHARED=1 UNICODE=1 BUILD=release clean
 +
'''NOTE:''' Make sure you use exactly the same options for this step and for the build step below. The clean target uses these variables and only cleans the specified version of the generated object and library files (so it will actually not clean the intended files if these variables are not identical).
  
== Post compilation steps (before running C::B) ==
+
'''NOTE:''' If you still have problems with compiling after cleaning, you could try to manually remove the gcc_msw directory under the build\msw directory. This directory is the place where the object files are stored.
  
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.
+
When everything is clean you can start actually compiling wxWidgets:
 +
mingw32-make -f makefile.gcc  MONOLITHIC=1 SHARED=1 UNICODE=1 BUILD=release
  
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  [ftp://ftp.uu.net/pub/archiving/zip/WIN32/ here].
+
'''NOTE:''' These options are the officially supported Code::Blocks options. If you want another version of wxWidgets (debug or non-unicode) you still have to make sure you build a MONOLITHIC version (one big DLL) for linking Code::Blocks against.
  
----------
+
Now you can get a cup of coffee or do something else because this step takes some time. Make sure there was no compilation error before you continue.
  
Edit: I didn't see any update.bat script but no matter.  Two changes to this howto to get everything to work.
+
'''NOTE:''' If you're having errors because of libjpeg, you might want to look at [http://sourceforge.net/tracker/?func=detail&atid=309863&aid=1606032&group_id=9863 this patch]
<br>
 
1.  When creating a wx project in codeblocks, the link stage fails with cannot find -lwxmsw.  I needed to:<br>
 
copy C:\wxWidgets-2.6.1\lib\codeblocks\libwxmsw26.a to C:\wxWidgets-2.6.1\lib\codeblocks\libwxmsw.a <br>
 
copy C:\wxWidgets-2.6.1\lib\codeblocks\libwxmsw26_stc.a to C:\wxWidgets-2.6.1\lib\codeblocks\libwxmsw_stc.a <br>
 
  
or mess with the autogenerated makefile (they don't use WX_VER anymore it seems...) which is more of a hassle. <br>
+
== Compiling Code::Blocks ==
<br>
+
=== Setting up paths ===
2.  You will still get --enable-auto-import errors.  Looks like you just need to add a define: <br>
+
Before finally compiling Code::Blocks itself, you need to setup the paths:
project->build options->compiler->#defines <br>
+
*Open the Code::Blocks project (CodeBlocks.cbp).
WXUSINGDLL <br>
+
*It will ask you to define a [[Global compiler variables|Global variable]]
<br>
+
*Set the path to where you have wxWidgets installed (e.g. "c:\wxWidgets-2.6.2").
Lastly it will look for wxmsw26_gcc_cb.dll and not find it.  Either put  <br>
+
*Compile Code::Blocks.
C:\wxWidgets-2.6.1\lib\codeblocks in your PATH, put wxmsw26_gcc_cb.dll and wxmsw26_stc_gcc_cb.dll in C:\windows\system32, or add C:\wxWidgets-2.6.1\lib\codeblocks to compile->compiler options->programs->additional paths <br>
 
<br>
 
Rebuild and everything should run ok.
 
<br>
 
<br>
 
====Building wxWidgets 2.6.1 mingw32 & vc++ toolkit 2003 ====
 
<br>
 
I'll just throw in my notes on the process for both compiler versions as getting vc++ toolkit to work is quite a pain.  Code blocks needs a couple changes to support wxWidgets on the vc++ toolkit seamlessly.
 
<br>
 
--------------------
 
for mingw32 compiler
 
--------------------
 
<br>
 
<b>
 
cd <WXWIN>\build\msw <br>
 
mingw32-make -f makefile.gcc USE_XRC=1 SHARED=1 MONOLITHIC=1 BUILD=release UNICODE=0 VENDOR=cb clean <br>
 
mingw32-make -f makefile.gcc USE_XRC=1 SHARED=1 MONOLITHIC=1 BUILD=release UNICODE=0 VENDOR=cb <br>
 
</b>
 
<i>
 
stc is no longer needed for latest codeblocks (cvs version) which uses wxscintilla: <br>
 
cd ..\..\contrib\build\stc <br>
 
mingw32-make -f makefile.gcc USE_XRC=1 SHARED=1 MONOLITHIC=1 BUILD=release UNICODE=0 VENDOR=cb clean <br>
 
mingw32-make -f makefile.gcc USE_XRC=1 SHARED=1 MONOLITHIC=1 BUILD=release UNICODE=0 VENDOR=cb <br>
 
</i>
 
<b>
 
cd <WXWIN>\lib; move gcc_dll codeblocks_gcc<br>
 
</b>
 
<br>
 
codeblocks <br>
 
<pre>
 
project->build options
 
directories->compiler
 
<WXWIN>\lib\codeblocks_gcc\msw
 
<WXWIN>\include
 
<WXWIN>\contrib\include
 
directories->linker
 
<WXWIN>\lib\codeblocks_gcc
 
directories->resource compiler
 
<WXWIN>\include
 
compiler->#defines
 
WXUSINGDLL
 
  
compile->compiler options
+
=== Post compilation steps ===
programs->additional paths
+
When the compilation process is finished, simply run the update.bat script. It will ensure that all resource files Code::Blocks uses are in the right place and up to date.
C:\wxWidgets-2.6.1\lib\codeblocks_gcc
 
-OR- copy C:\wxWidgets-2.6.1\lib\codeblocks_gcc\wxmsw26_gcc_cb.dll
 
    to application exe directory or c:\windows\system32
 
-OR- change project->properties->targets->execution working dir
 
    to C:\wxWidgets-2.6.1\lib\codeblocks_gcc (not recommended)
 
  
copy C:\wxWidgets-2.6.1\lib\codeblocks_gcc\libwxmsw26.a
+
== Building wxWidgets 2.6.2 using VC++ Toolkit 2003 ==
to C:\wxWidgets-2.6.1\lib\codeblocks_gcc\libwxmsw.a
+
I'll just throw in my notes on the process for both compiler versions as getting VC++ toolkit to work is quite a pain. Code::Blocks needs a couple of changes to support wxWidgets with the VC++ toolkit seamlessly.
copy C:\wxWidgets-2.6.1\lib\codeblocks_gcc\libwxmsw26_stc.a
 
to C:\wxWidgets-2.6.1\lib\codeblocks_gcc\libwxmsw_stc.a
 
  
compile->rebuild
 
</pre>
 
------------------------------
 
for vc++ toolkit 2003 compiler
 
------------------------------
 
 
install VCToolkitSetup.exe <br>
 
install VCToolkitSetup.exe <br>
 
install PlatformSDK <br>
 
install PlatformSDK <br>
Line 189: Line 102:
 
<b>
 
<b>
 
cd <WXWIN>\build\msw <br>
 
cd <WXWIN>\build\msw <br>
nmake -f makefile.vc USE_XRC=1 SHARED=1 MONOLITHIC=1 BUILD=release UNICODE=0 VENDOR=cb clean <br>
+
nmake -f makefile.vc USE_XRC=1 SHARED=1 MONOLITHIC=1 BUILD=release UNICODE=0 CFG=NonUnicode clean <br>
nmake -f makefile.vc USE_XRC=1 SHARED=1 MONOLITHIC=1 BUILD=release UNICODE=0 VENDOR=cb <br>
+
nmake -f makefile.vc USE_XRC=1 SHARED=1 MONOLITHIC=1 BUILD=release UNICODE=0 CFG=NonUnicode <br>
 
</b>
 
</b>
<i>
+
 
stc is no longer needed for latest codeblocks (cvs version) which uses wxscintilla: <br>
 
cd ..\..\contrib\build\stc <br>
 
nmake -f makefile.vc USE_XRC=1 SHARED=1 MONOLITHIC=1 BUILD=release UNICODE=0 VENDOR=cb clean <br>
 
nmake -f makefile.vc USE_XRC=1 SHARED=1 MONOLITHIC=1 BUILD=release UNICODE=0 VENDOR=cb <br>
 
</i>
 
 
<b>
 
<b>
 
cd <WXWIN>\lib; move vc_dll codeblocks_vc<br>
 
cd <WXWIN>\lib; move vc_dll codeblocks_vc<br>
Line 224: Line 132:
 
compile->compiler options
 
compile->compiler options
 
programs->additional paths
 
programs->additional paths
C:\wxWidgets-2.6.1\lib\codeblocks_vc
+
C:\wxWidgets-2.6.2\lib\codeblocks_vc
-OR- copy C:\wxWidgets-2.6.1\lib\codeblocks_vc\wxmsw26_vc_cb.dll
+
-OR- copy C:\wxWidgets-2.6.2\lib\codeblocks_vc\wxmsw26_vc_custom.dll
 
     to application exe directory or c:\windows\system32
 
     to application exe directory or c:\windows\system32
 
-OR- change project->properties->targets->execution working dir
 
-OR- change project->properties->targets->execution working dir
     to C:\wxWidgets-2.6.1\lib\codeblocks_vc (not recommended)
+
     to C:\wxWidgets-2.6.2\lib\codeblocks_vc (not recommended)
  
 
compile->compiler options
 
compile->compiler options
Line 238: Line 146:
 
add C:\Program Files\Microsoft Platform SDK\Lib
 
add C:\Program Files\Microsoft Platform SDK\Lib
  
copy C:\wxWidgets-2.6.1\lib\codeblocks_vc\wxmsw26.exp
+
copy C:\wxWidgets-2.6.2\lib\codeblocks_vc\wxmsw26.exp
     to C:\wxWidgets-2.6.1\lib\codeblocks_vc\wxmsw.exp
+
     to C:\wxWidgets-2.6.2\lib\codeblocks_vc\wxmsw.exp
copy C:\wxWidgets-2.6.1\lib\codeblocks_vc\wxmsw26.lib
+
copy C:\wxWidgets-2.6.2\lib\codeblocks_vc\wxmsw26.lib
     to C:\wxWidgets-2.6.1\lib\codeblocks_vc\wxmsw.lib
+
     to C:\wxWidgets-2.6.2\lib\codeblocks_vc\wxmsw.lib
copy C:\wxWidgets-2.6.1\lib\codeblocks_vc\wxmsw26_stc.exp
+
copy C:\wxWidgets-2.6.2\lib\codeblocks_vc\wxmsw26_stc.exp
     to C:\wxWidgets-2.6.1\lib\codeblocks_vc\wxmsw_stc.exp
+
     to C:\wxWidgets-2.6.2\lib\codeblocks_vc\wxmsw_stc.exp
copy C:\wxWidgets-2.6.1\lib\codeblocks_vc\wxmsw26_stc.lib
+
copy C:\wxWidgets-2.6.2\lib\codeblocks_vc\wxmsw26_stc.lib
     to C:\wxWidgets-2.6.1\lib\codeblocks_vc\wxmsw_stc.lib
+
     to C:\wxWidgets-2.6.2\lib\codeblocks_vc\wxmsw_stc.lib
  
 
compile->rebuild
 
compile->rebuild
Line 251: Line 159:
 
<br>
 
<br>
 
building from the commandline (wxwidgets demos) <br>
 
building from the commandline (wxwidgets demos) <br>
nmake -f makefile.vc SHARED=1 MONOLITHIC=1 BUILD=release <br>
+
nmake -f makefile.vc SHARED=1 MONOLITHIC=1 BUILD=release
<br>
 
 
 
====Building codeblocks from source (using makefile)====
 
 
 
Codeblocks can be used to build the source but here is how to build using just makefiles.
 
 
 
<pre>
 
build wxWidgets-2.6.1 dll using mingw32
 
  mingw32-make -f makefile.gcc USE_XRC=1 SHARED=1 MONOLITHIC=1 BUILD=release UNICODE=1 VENDOR=cb clean
 
  mingw32-make -f makefile.gcc USE_XRC=1 SHARED=1 MONOLITHIC=1 BUILD=release UNICODE=1 VENDOR=cb
 
copy C:\wxWidgets-2.6.1\lib\gcc_dll to C:\wxWidgets-2.6.1\lib\gcc_dllUnicode (copy since wxDockIt expects gcc_dll to exists)
 
checkout CVS source codeblocks module (used VERSION_1_0 branch)
 
(beware path lengths - best to checkout to root directory - c:\)
 
download http://prdownloads.sourceforge.net/wxextended/wxDockIt_2.1.zip?download
 
extract wxDockIt to codeblocks\src\src
 
patch codeblocks\src\src\wxDockit\build\msw\makefile.gcc
 
  change "$(CXX) -shared -fPIC -o $@ $(WXDOCKIT_DLL_OBJECTS) $(LDFLAGS) -mthreads -L$(WX_DIR)$(__WXLIBPATH_FILENAMES) -L..\..\$(__WXDOCKIT_OUTPUT_FOLDER_FILENAMES_1) $(__DEBUGINFO) -mthreads -Wl,--out-implib,..\..\lib\gcc_dll\libwxdockit$(WXLIBPOSTFIX).a  -lwxmsw$(WX_VERSION)$(WXLIBPOSTFIX)_adv -lwxbase$(WX_VERSION)$(WXLIBPOSTFIX)_xml -lwxmsw$(WX_VERSION)$(WXLIBPOSTFIX)_core -lwxbase$(WX_VERSION)$(WXLIBPOSTFIX) -lwxtiff$(WX3RDPARTLIBPOSTFIX) -lwxjpeg$(WX3RDPARTLIBPOSTFIX) -lwxpng$(WX3RDPARTLIBPOSTFIX) -lwxzlib$(WX3RDPARTLIBPOSTFIX) -lwxregex$(WXLIBPOSTFIX) -lwxexpat$(WX3RDPARTLIBPOSTFIX) -lkernel32 -luser32 -lgdi32 -lcomdlg32 -lwinspool -lwinmm -lshell32 -lcomctl32 -lole32 -loleaut32 -luuid -lrpcrt4 -ladvapi32 -lwsock32 -lodbc32"
 
  to    "$(CXX) -shared -fPIC -o $@ $(WXDOCKIT_DLL_OBJECTS) $(LDFLAGS) -mthreads -L$(WX_DIR)$(__WXLIBPATH_FILENAMES) -L..\..\$(__WXDOCKIT_OUTPUT_FOLDER_FILENAMES_1) $(__DEBUGINFO) -mthreads -Wl,--out-implib,..\..\lib\gcc_dll\libwxdockit$(WXLIBPOSTFIX).a  -lwxmsw$(WX_VERSION)$(WXLIBPOSTFIX) -lwxtiff$(WX3RDPARTLIBPOSTFIX) -lwxjpeg$(WX3RDPARTLIBPOSTFIX) -lwxpng$(WX3RDPARTLIBPOSTFIX) -lwxzlib$(WX3RDPARTLIBPOSTFIX) -lwxregex$(WXLIBPOSTFIX) -lwxexpat$(WX3RDPARTLIBPOSTFIX) -lkernel32 -luser32 -lgdi32 -lcomdlg32 -lwinspool -lwinmm -lshell32 -lcomctl32 -lole32 -loleaut32 -luuid -lrpcrt4 -ladvapi32 -lwsock32 -lodbc32"
 
compile wxDockIt
 
  cd codeblocks\src\src\wxDockit\build\msw
 
  mingw32-make -f makefile.gcc WX_DIR=C:\wxWidgets-2.6.1 WX_SHARED=1 WX_DEBUG=0 WX_UNICODE=1 WX_VERSION=26 clean
 
  mingw32-make -f makefile.gcc WX_DIR=C:\wxWidgets-2.6.1 WX_SHARED=1 WX_DEBUG=0 WX_UNICODE=1 WX_VERSION=26
 
move codeblocks\src\src\wxDockit\build\msw\gcc_dll to codeblocks\src\src\wxDockit\build\msw\gcc_dllUnicode
 
edit codeblocks\src\src\Makefile.wx2.6
 
  change WX_DIR=C:/Devel/wxWindows-2.6.1 to WX_DIR=C:/wxWidgets-2.6.1
 
  change WX_CFG=NonUnicode to WX_CFG=Unicode
 
  global search+replace: replace " -lwxmsw26" with " -lwxmsw26u"
 
  global search+replace: replace "/msw" with "/mswu"
 
  replace "-Lsrc/wxDockit/lib" with "-Lsrc/wxDockit/lib/gcc_dll$(WX_CFG)"
 
  replace "..\wxDockit\lib\libwxdockit.a" with "src\wxDockit\lib\gcc_dll$(WX_CFG)\libwxdockitu.a"
 
edit C:\wxWidgets-2.6.1\lib\gcc_dllUnicode\mswu\wx\setup.h
 
  change "#define wxUSE_UNICODE 0" to "#define wxUSE_UNICODE 1"
 
start->run->cmd
 
cd codeblocks\src
 
mingw32-make -f Makefile.wx2.6 clean
 
mingw32-make -f Makefile.wx2.6
 
download ftp://ftp.info-zip.org/pub/infozip/MSDOS/zip231x.zip (infozip)
 
put zip.exe in some directory in your PATH (e.g. C:\MinGW\bin)
 
copy C:\wxWidgets-2.6.1\lib\gcc_dllUnicode\wxmsw26u_gcc_cb.dll to codeblocks\src\output\wxmsw26u_gcc_cb.dll and codeblocks\src\devel\wxmsw26u_gcc_cb.dll
 
copy src\src\wxDockit\lib\gcc_dllUnicode\wxdockitu.dll to and codeblocks\src\output\wxdockitu.dll and codeblocks\src\devel\wxdockitu.dll
 
update.bat
 
output\CodeBlocks.exe
 
</pre>
 

Latest revision as of 19:57, 30 April 2008

These are the instructions for compiling wxWidgets for use with Code::Blocks. They are primarily intended in preparation for compiling Code::Blocks itself but (hopefully) may also help installing wxWidgets for general development using that framework.

Although these instructions are targeted at the Windows operating system, it should be possible to apply them with slight adjustments to other platforms, since we make use of MinGW.

Warning

From November 2007 onwards you need wxWidgets 2.8.6 to develop Code::Blocks. See: Compiling wxWidgets 2.8.6 to develop Code::Blocks (MSW)

Installing MinGW

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

Grab the latest MinGW files from the MinGW download site and install them into a directory of your choice.

NOTE: In these instructions we call the MinGW directory <MINGW>, therefore you have to replace it with your corresponding directory.

NOTE: The files are compressed tarballs. You may need a third-party extraction utility like 7-Zip in order to extract them.

You need at least the following files:

After successful installation of the above, make sure you have the following directories included in your PATH environment variable:

  • <MINGW>\bin;
  • <MINGW>\mingw32\bin;

(You can add them by right-clicking the My Computer icon on your desktop and selecting Properties. Then select the Advanced tab and choose Environment Variables.)

Installing the wxWidgets source code

The wxWidgets 2.6.2 distribution can be found at the wxWidgets download site. (Note that there is also a winhelp file available.) You can choose between an installer and a zip file. You can just get the zip file because the installer is also a zipped version.

If you use the plain zip version, make sure to unzip using the full path. Otherwise the directories won't be created correctly.

NOTE: For the remainder of these instructions we call the wxWidgets directory <WXWIN>. You have to change it to your corresponding directory (e.g. "c:\wxWidgets-2.6.2").

NOTE: You do not need MSYS. Furthermore, you cannot have MSYS in your path, or the wxWidgets compilation will fail. Thus, if you have MSYS installed, ensure that <MSYS>\bin is not in your path before compiling wxWidgets. wxWidgets must be compiled from a "regular" command line (like cmd.exe), not from a Unix-like shell. The same problem could arise if Cygwin is in the path.

Checking make version

If you didn't install MinGW yourself you have to ensure you are using a recent enough version of the make utility. Open a command prompt and type:

mingw32-make -v

The version should read 3.80 or greater, else you need to install a newer version.

Building wxWidgets

Now it is time to compile wxWidgets, open the command promt and change to the wxWidgets directory:

cd <WXWIN>\build\msw

NOTE: The following instructions do not work with MSYS, or other forms of Unix on Windows.

Now the first thing to do is to clean up the source:

mingw32-make -f makefile.gcc MONOLITHIC=1 SHARED=1 UNICODE=1 BUILD=release clean 

NOTE: Make sure you use exactly the same options for this step and for the build step below. The clean target uses these variables and only cleans the specified version of the generated object and library files (so it will actually not clean the intended files if these variables are not identical).

NOTE: If you still have problems with compiling after cleaning, you could try to manually remove the gcc_msw directory under the build\msw directory. This directory is the place where the object files are stored.

When everything is clean you can start actually compiling wxWidgets:

mingw32-make -f makefile.gcc  MONOLITHIC=1 SHARED=1 UNICODE=1 BUILD=release

NOTE: These options are the officially supported Code::Blocks options. If you want another version of wxWidgets (debug or non-unicode) you still have to make sure you build a MONOLITHIC version (one big DLL) for linking Code::Blocks against.

Now you can get a cup of coffee or do something else because this step takes some time. Make sure there was no compilation error before you continue.

NOTE: If you're having errors because of libjpeg, you might want to look at this patch

Compiling Code::Blocks

Setting up paths

Before finally compiling Code::Blocks itself, you need to setup the paths:

  • Open the Code::Blocks project (CodeBlocks.cbp).
  • It will ask you to define a Global variable
  • Set the path to where you have wxWidgets installed (e.g. "c:\wxWidgets-2.6.2").
  • Compile Code::Blocks.

Post compilation steps

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

Building wxWidgets 2.6.2 using VC++ Toolkit 2003

I'll just throw in my notes on the process for both compiler versions as getting VC++ toolkit to work is quite a pain. Code::Blocks needs a couple of changes to support wxWidgets with the VC++ toolkit seamlessly.

install VCToolkitSetup.exe
install PlatformSDK
install .NET Framework SDK Version 1.1
run PlatformSDK->Run all Windows XP 32-bit Build Environment (Retail) batch files (find them in PlatformSDK\Setup)
C:\Program Files\Microsoft Visual C++ Toolkit 2003\Vc7\bin\vcvars32.bat (not needed)

The following environment vars must be set/modified/added via 'Control Panel | System | Advanced | Environment Variables'.

set DOTNETSDK=C:\Program Files\Microsoft.NET\SDK\v1.1 (not needed)
set MSVC=C:\Program Files\Microsoft Visual C++ Toolkit 2003
set MSSDK=C:\Program Files\Microsoft Platform SDK
set VC7=C:\Program Files\Microsoft Visual Studio .NET 2003\Vc7
set INCLUDE=%MSVC%\include;%MSSDK%\include
set LIB=%MSVC%\lib;%MSSDK%\lib;%VC7%\lib
set PATH=%MSVC%\bin;%MSSDK%\bin;%PATH%
set PATH=%PATH%;%MSSDK%\bin\Win64

cd <WXWIN>\build\msw
nmake -f makefile.vc USE_XRC=1 SHARED=1 MONOLITHIC=1 BUILD=release UNICODE=0 CFG=NonUnicode clean
nmake -f makefile.vc USE_XRC=1 SHARED=1 MONOLITHIC=1 BUILD=release UNICODE=0 CFG=NonUnicode

cd <WXWIN>\lib; move vc_dll codeblocks_vc

codeblocks

project->build options
	directories->compiler
		<WXWIN>\lib\codeblocks_vc\msw 
		<WXWIN>\include 
		<WXWIN>\contrib\include
	directories->linker
		<WXWIN>\lib\codeblocks_vc
	directories->resource compiler
		<WXWIN>\include
	compiler->#defines
		WXUSINGDLL
	compiler->compiler flags
		enable c++ exception handling (or other options: /GX [same as /EHsc])
	compiler->other options
		delete -D__GNUWIN32__
	linker->link libraries
		delete ctl3d32

compile->compiler options
	programs->additional paths
		C:\wxWidgets-2.6.2\lib\codeblocks_vc
-OR- copy C:\wxWidgets-2.6.2\lib\codeblocks_vc\wxmsw26_vc_custom.dll
     to application exe directory or c:\windows\system32
-OR- change project->properties->targets->execution working dir
     to C:\wxWidgets-2.6.2\lib\codeblocks_vc (not recommended)

compile->compiler options
	programs->additional paths
		C:\Program Files\Microsoft Platform SDK\Bin
 	directories->compiler
		add C:\Program Files\Microsoft Platform SDK\Include		
	directories->linker
		add C:\Program Files\Microsoft Platform SDK\Lib

copy C:\wxWidgets-2.6.2\lib\codeblocks_vc\wxmsw26.exp
     to C:\wxWidgets-2.6.2\lib\codeblocks_vc\wxmsw.exp
copy C:\wxWidgets-2.6.2\lib\codeblocks_vc\wxmsw26.lib
     to C:\wxWidgets-2.6.2\lib\codeblocks_vc\wxmsw.lib
copy C:\wxWidgets-2.6.2\lib\codeblocks_vc\wxmsw26_stc.exp
     to C:\wxWidgets-2.6.2\lib\codeblocks_vc\wxmsw_stc.exp
copy C:\wxWidgets-2.6.2\lib\codeblocks_vc\wxmsw26_stc.lib
     to C:\wxWidgets-2.6.2\lib\codeblocks_vc\wxmsw_stc.lib

compile->rebuild


building from the commandline (wxwidgets demos)
nmake -f makefile.vc SHARED=1 MONOLITHIC=1 BUILD=release