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

From Code::Blocks
(→‎Building wxWidgets Code: mention a patch and a compiler option to build wx3)
 
(13 intermediate revisions by 3 users not shown)
Line 1: Line 1:
'''Note, the wxWidgets 2.9.0 release is a development release NOT intended for production use.'''  
+
'''Note, compiling Code::Blocks linked against the wxWidgets 3.0.0 is NOT ready for stable use; CodeBlocks developers are working hard to stabilize it, also patches are welcome to accelerate the migration'''
  
 
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.
 
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.
Line 10: Line 10:
  
 
== Installing the wxWidgets Source Code ==
 
== Installing the wxWidgets Source Code ==
The wxWidgets 2.9.0 distribution can be found at the [http://www.wxwidgets.org/downloads/#previous_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.
+
The wxWidgets 3.0.0 distribution can be found at the [http://www.wxwidgets.org/downloads/#latest_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:''' For the remainder of these instructions we call the wxWidgets directory ''<WXWIN>''. You have to change it to your corresponding directory (e.g. "c:\wxMSW-2.9.0\wxWidgets-2.9.0").
+
'''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:\wxMSW-3.0.0\wxWidgets-3.0.0").
  
 
'''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.
 
'''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.
Line 27: Line 27:
  
 
== Building wxWidgets ==
 
== Building wxWidgets ==
=== Editing the values to be used in wx/setup.h ===
 
Note, changing the value of wxUSE_STC prevents error compiling Code::Blocks because it has its own custom version of STC.
 
===== Open the folder <WXWIN>\include\wx\msw\ =====
 
===== If the file setup.h does not exist copy the file setup0.h to setup.h =====
 
===== With an text editor open <WXWIN>\include\wx\msw\setup.h =====
 
===== Change "#define wxUSE_STC 1" to "#define wxUSE_STC 0" =====
 
===== Save the changes =====
 
 
 
=== Changing Directory and Setting Path ===
 
=== Changing Directory and Setting Path ===
 
To compile wxWidgets, open the command prompt window and change to the wxWidgets directory:
 
To compile wxWidgets, open the command prompt window and change to the wxWidgets directory:
Line 44: Line 36:
 
=== Cleaning wxWidgets Code ===
 
=== Cleaning wxWidgets Code ===
 
Now clean up the source:
 
Now clean up the source:
  <tt>mingw32-make -f makefile.gcc MONOLITHIC=1 SHARED=1 UNICODE=1 USE_STC=0 USE_PROPGRID=1 BUILD=release clean</tt>
+
  <tt>mingw32-make -f makefile.gcc USE_XRC=1 SHARED=1 MONOLITHIC=1 BUILD=release UNICODE=1 USE_OPENGL=1 VENDOR=cb CXXFLAGS="-fno-keep-inline-dllexport" clean</tt>
 
'''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. (It will not clean the intended files if these variables are not identical.)
 
'''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. (It will 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.
+
'''NOTE:''' If you still have problems with compiling after cleaning, you could try to manually remove the gcc_dll directory under the build\msw directory. This directory is the place where the object files are stored.
  
 
=== Building wxWidgets Code ===
 
=== Building wxWidgets Code ===
 
When everything is clean you can start compiling wxWidgets:
 
When everything is clean you can start compiling wxWidgets:
  <tt>mingw32-make -f makefile.gcc MONOLITHIC=1 SHARED=1 UNICODE=1 USE_STC=0 USE_PROPGRID=1 BUILD=release</tt>
+
  <tt>mingw32-make -f makefile.gcc USE_XRC=1 SHARED=1 MONOLITHIC=1 BUILD=release UNICODE=1 USE_OPENGL=1 VENDOR=cb CXXFLAGS="-fno-keep-inline-dllexport" >log.txt 2>&1</tt>
 +
 
 +
'''NOTE:''' 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.
 +
 
 +
'''NOTE:''' If you are building wx3.0.2 with GCC 4.9.x or GCC 5.x, you will get compiler error, thus a patch is need, see discussion here: [/index.php/topic,20607.msg140163/topicseen.html#msg140163 Build C::B against wx3.02 with gcc 5.2 under Windows]
 +
 
 +
'''NOTE:''' There is an compiler option needed if you want to suppress the compiler warnings, see: [/index.php/topic,20382.msg140167.html#msg140167 Re: TDM-GCC 5 series (Latest: 5.1.0 - 2015-06-28)]
  
'''NOTE:''' These options are not the officially-supported Code::Blocks options because there is no official options for wxWidgets 2.9. The option of "USE_STC=0" is needed because Code::Blocks has its own customized version of it; and, if both exists it will cause errors building Code::Blocks plugins. The option "USE_PROPGRID=1" is used to help building plugins that depend on wxPropertyGrid. 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.
 
  
 
Patience. This step takes time. Make sure there was no compilation error before you continue.
 
Patience. This step takes time. Make sure there was no compilation error before you continue.
  
 
== Compiling Code::Blocks ==
 
== Compiling Code::Blocks ==
 +
=== Code::Blocks project to use===
 +
No patches are needed to compile Code::Blocks with wxWidgets 3.0, just use the project/workspace-files with the ''_wx30'' in the name and call ''update30.bat'' to update the resources.
 +
 +
That does not mean, that everything runs absolutely bug-free, but we are working on it.
 +
 +
As always patches are welcome.
 +
 
=== Setting up paths ===
 
=== Setting up paths ===
 
Before finally compiling Code::Blocks itself, you need to setup the paths:
 
Before finally compiling Code::Blocks itself, you need to setup the paths:
*Open the Code::Blocks project (CodeBlocks.cbp).
+
*Open the Code::Blocks project (CodeBlocks_wx30.cbp).
*It will ask you to define a [[Global compiler variables|Global variable]]
+
*It will ask you to define a [[Global compiler variables|Global variable]] named "wx30"
*Set the path to where you have wxWidgets installed (e.g. "c:\wxMSW-2.9.0\wxWidgets-2.9.0").
+
*Set the path to where you have wxWidgets installed (e.g. "c:\wxMSW-3.0.0\wxWidgets-3.0.0").
 +
*Set the global variable cb_release_type to "-g". (no quote is needed when your enter the text)
 
*Compile Code::Blocks.
 
*Compile Code::Blocks.
 +
 +
'''NOTE:''' A zip.exe file should be in your PATH, so they can run post steps correctly, see [https://wiki.codeblocks.org/index.php?title=Installing_Code::Blocks_from_source_on_Windows#zip.exe 1.6 zip.exe] for some details about zip.exe
 +
  
 
=== Post compilation steps ===
 
=== 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.
+
When the compilation process is finished, simply run the update30.bat script. It will ensure that all resource files Code::Blocks uses are in the right place and up to date.
 +
 
 +
=== Reference ===
 +
* Forum discussion:[/index.php/topic,18412.msg125957.html#msg125957 Re: wxWidgets 3.0 and Code::Blocks files question?]
 +
* [[Installing Code::Blocks from source on Windows]]
 +
* Note that PCH is disabled in Codeblocks_wx30.cbp, because it cause GCC build error (a bug in GCC 4.8.x [http://gcc.gnu.org/bugzilla/show_bug.cgi?id=56926 Bug 56926 – Crash (without ICE) while compiling Boost.Math]), see discussions here: [/index.php/topic,18412.msg126028.html#msg126028 Re: wxWidgets 3.0 and Code::Blocks files question?] and [/index.php/topic,18568.msg127102.html#msg127102 Patches for Compiling Code::Blocks against wxWidgets 3.0 using MinGW GCC 4.8.1]. As of 2015-09-27, there is a gcc suite which have PCH crash issue fixed, see forum post [/index.php/topic,18568.msg140107.html#msg140107 Re: Patches for Compiling Code::Blocks against wxWidgets 3.0 using MinGW GCC 4.8.1]

Latest revision as of 06:20, 27 September 2015

Note, compiling Code::Blocks linked against the wxWidgets 3.0.0 is NOT ready for stable use; CodeBlocks developers are working hard to stabilize it, also patches are welcome to accelerate the migration

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.

Installing MinGW

Directions to install MinGW for Code::Blocks can be found here. MinGW installation

Installing the wxWidgets Source Code

The wxWidgets 3.0.0 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:\wxMSW-3.0.0\wxWidgets-3.0.0").

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.

NOTE: For the remainder of these instructions we call the MinGW directory <MINGW>. You have to change it to your corresponding directory (e.g. "C:\MinGW").

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:

cd <MINGW>\bin
mingw32-make -v

The version should read 3.80 or higher.

Building wxWidgets

Changing Directory and Setting Path

To compile wxWidgets, open the command prompt window and change to the wxWidgets directory:

cd /d <WXWIN>\build\msw
SET PATH=<MINGW>\bin

NOTE: This is normally SET PATH=C:\MingGW\bin

Cleaning wxWidgets Code

Now clean up the source:

mingw32-make -f makefile.gcc USE_XRC=1 SHARED=1 MONOLITHIC=1 BUILD=release UNICODE=1 USE_OPENGL=1 VENDOR=cb CXXFLAGS="-fno-keep-inline-dllexport" 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. (It will 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_dll directory under the build\msw directory. This directory is the place where the object files are stored.

Building wxWidgets Code

When everything is clean you can start compiling wxWidgets:

mingw32-make -f makefile.gcc USE_XRC=1 SHARED=1 MONOLITHIC=1 BUILD=release UNICODE=1 USE_OPENGL=1 VENDOR=cb CXXFLAGS="-fno-keep-inline-dllexport" >log.txt 2>&1

NOTE: 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.

NOTE: If you are building wx3.0.2 with GCC 4.9.x or GCC 5.x, you will get compiler error, thus a patch is need, see discussion here: [/index.php/topic,20607.msg140163/topicseen.html#msg140163 Build C::B against wx3.02 with gcc 5.2 under Windows]

NOTE: There is an compiler option needed if you want to suppress the compiler warnings, see: [/index.php/topic,20382.msg140167.html#msg140167 Re: TDM-GCC 5 series (Latest: 5.1.0 - 2015-06-28)]


Patience. This step takes time. Make sure there was no compilation error before you continue.

Compiling Code::Blocks

Code::Blocks project to use

No patches are needed to compile Code::Blocks with wxWidgets 3.0, just use the project/workspace-files with the _wx30 in the name and call update30.bat to update the resources.

That does not mean, that everything runs absolutely bug-free, but we are working on it.

As always patches are welcome.

Setting up paths

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

  • Open the Code::Blocks project (CodeBlocks_wx30.cbp).
  • It will ask you to define a Global variable named "wx30"
  • Set the path to where you have wxWidgets installed (e.g. "c:\wxMSW-3.0.0\wxWidgets-3.0.0").
  • Set the global variable cb_release_type to "-g". (no quote is needed when your enter the text)
  • Compile Code::Blocks.

NOTE: A zip.exe file should be in your PATH, so they can run post steps correctly, see 1.6 zip.exe for some details about zip.exe


Post compilation steps

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

Reference

  • Forum discussion:[/index.php/topic,18412.msg125957.html#msg125957 Re: wxWidgets 3.0 and Code::Blocks files question?]
  • Installing Code::Blocks from source on Windows
  • Note that PCH is disabled in Codeblocks_wx30.cbp, because it cause GCC build error (a bug in GCC 4.8.x Bug 56926 – Crash (without ICE) while compiling Boost.Math), see discussions here: [/index.php/topic,18412.msg126028.html#msg126028 Re: wxWidgets 3.0 and Code::Blocks files question?] and [/index.php/topic,18568.msg127102.html#msg127102 Patches for Compiling Code::Blocks against wxWidgets 3.0 using MinGW GCC 4.8.1]. As of 2015-09-27, there is a gcc suite which have PCH crash issue fixed, see forum post [/index.php/topic,18568.msg140107.html#msg140107 Re: Patches for Compiling Code::Blocks against wxWidgets 3.0 using MinGW GCC 4.8.1]