vignette

Config Code::Blocks

vignette

fr flag

 

---------------------------------------------
Preparing code::blocks
---------------------------------------------

Since Ubuntu 18.04, the compile option "pie" (position independent executable) is enabled by default. It strengthens a bit the security.
An unpleasant side effect is that the compiled file will be seen as a dll and not an executable by the file manager.
That will prevent launching the software by double clicking it (although it will work fine from a terminal windows or with the launcher)
If you want to keep the previous behaviour you need to add the -no-pie linker option, or the exe will be considered as dll and won't launch.
It can by done from code::blocks' interface, "settings" tab.
settings->Compiler(GNU GCC Compiler)->Linker Settings-> other linker options here you add -no-pie

For a 32 bits Windows target
Configure a new compiler with an explicit name (e.g cross_compil_win32 )
Settings->Compiler then copy the default compiler and give it the new name.
Fetch the executables in the /usr directory
For C :i686-w64-mingw32-gcc
For C++ :i686-w64-mingw32-g++
linker for dynamic lib:i686-w64-mingw32-g++ (!!! not gcc)
linker for static lib: i686-w64-mingw32-ar
ressources compiler`/opt/Persowx305_Win32/bin/wx-config --host=i686-w64-mingw32 --rescomp`

For a 64 bits Windows target
Configure a new compiler with an explicit name (e.g cross_compil_win64 )
Settings->Compiler then copy the default compiler and give it the new name.
Fetch the executables in the /usr directory
pour C :x86_64-w64-mingw32-gcc
pour C++ :x86_64-w64-mingw32-g++
linker for dynamic lib:x86_64-w64-mingw32-g++ (!!! pas gcc)
linker for static lib: x86_64-w64-mingw32-ar
ressources compiler`/opt/Persowx305_Win64/bin/wx-config --host=x86_64-w64-mingw32 --rescomp`

For each compiler used in cross-compiling add in "linker other options" -static (to limit the dependancies)

---------------------------------------------
Tailoring the config file for each application (code::blocks cbp file)
---------------------------------------------

It's quicker to directly edit the cbp file in your pet text editor.
In the application's "cbp" file Set the path to wx-config in agreement with the chosen target.
For each of wxWidgets builds, this path is the "prefix" used at "configure" time.
Examples

For < Target title="ReleaseStatic305"> (To produce a Linux application based on wxWidgets 3.1.2)
In Compiler options :
< Add option="`/opt/Persowx305_Lin64/bin/wx-config --static --cflags --unicode=yes`" />
In linker options :
< Add option="`/opt/Persowx305_Lin64/bin/wx-config --unicode=yes --static --libs`" />

For < Target title="ReleaseWinStatic305_32"> (To produce a Windows 32bits application based on wxWidgets 3.1.2)
You need to specify the correct compiler in place of gcc :< Option compiler="cross_compil_win32" >
In Compiler options :
< Add option="`/opt/Persowx305_Win32/bin/wx-config --host=i686-w64-mingw32 --static --cflags --unicode=yes`" />
In linker options :
< Add option="`/opt/Persowx305_Win32/bin/wx-config --host=i686-w64-mingw32 --static --libs --unicode=yes`" />

For < Target title="ReleaseWinStatic305_64"> (To produce a Windows 64bits application based on wxWidgets 3.1.2)
You need to specify the correct compiler in place of gcc :< Option compiler="cross_compil_win64" >
In Compiler options :
< Add option="`/opt/Persowx305_Win64/bin/wx-config --host=x86_64-w64-mingw32 --static --cflags --unicode=yes`" />
In linker options :
< Add option="`/opt/Persowx305_Win64/bin/wx-config --host=x86_64-w64-mingw32 --static --libs --unicode=yes`" />


Some issues if RichText functions are involved. This workaround seems to work (but it smacks of tinkering).
In the linker options, you need to add : std,richtext
< Add option="`/opt/Persowx305_Win32/bin/wx-config --host=i686-w64-mingw32 --static --libs std,richtext --unicode=yes`" /> pour 32 bits
< Add option="`/opt/Persowx305_Win64/bin/wx-config --host=x86_64-w64-mingw32 --static --libs std,richtext --unicode=yes`" /> pour 64 bits
In normal compiling you need to add -lexpat
< Add option="`/opt/Persowx305_Lin64/bin/wx-config --unicode=yes --static --libs std,richtext`" />
< Add option="-lexpat" />

 

The "ProjectMiniMini" does ... a minimum, but the sources provide an example of cbp file.

 

Home