Win7:How to build with different Gcc versions and use them? Topic is solved

Do you have a question about makefiles, a compiler or IDE you are using and need to know how to set it up for wxWidgets or why it doesn't compile but other IDE's do ? Post your questions here.
Post Reply
User avatar
Parduz
I live to help wx-kind
I live to help wx-kind
Posts: 188
Joined: Fri Jan 30, 2015 1:48 pm
Location: Bologna, Italy

Win7:How to build with different Gcc versions and use them?

Post by Parduz »

The title is a bit short for what i think is a rather complex question.
My english is poor, so i'll go with short phrases trying to explain that i'd need and why.

What I have:
  • two BeagleBoneBlack boards (BBBs) with different Debian images: one have Gcc 4.9.2 and one with Gcc 6.3.0 and wxWidgets 3.0.3 linux libraries compiled by the BBBs (i mean: i use the BBB to compile)
  • A C++ GUI app with wxWidgets that is developed and debugged on Windows 7, then compiled by the BBBs themselves (so, each one uses the Gcc version it have installed)
  • Code::Blocks on the Windows7 PC
  • two MinGW32 versions in the Windows7 PC, the sames of the BBBs.
  • No system/user PATH and other variables set in Windows bout MinGW and wxWidgets: i want to do everything inside Code::Blocks or using BATCH files (which sets them but are not "stored" in the system).
What i need
Two different build of the wxWidgets on Win7, one for each MinGW version, so i can make the Code::BLock project compile the app using one of the two version (as different Targets) and debug them.


What i've tried to do
I've made two folders in the wxWidgets 3.0.3 directory, called "Build Win Debug 6.3" and "Build Win Debug 4.9"
Each of them contains a "StartEnv.bat" with this commands:

Code: Select all

@echo off
set PATH=C:\SVILUPPO\Toolchains\MinGW 6.3.0-1\bin;%PATH%
set WXWIN="%~dp0..\"
echo %WXWIN%
cd "%~dp0"
"C:\Windows\system32\cmd.exe"

By clicking on the StartEnv, i obtain a "DOS" windows with this environment settings:

Code: Select all

ALLUSERSPROFILE=C:\ProgramData
APPDATA=C:\Users\Parduz\AppData\Roaming
BORLAND_BIN=C:\PROGRAM FILES (X86)\BORLAND\BDS\4.0\BIN
CommonProgramFiles=C:\Program Files\Common Files
CommonProgramFiles(x86)=C:\Program Files (x86)\Common Files
CommonProgramW6432=C:\Program Files\Common Files
COMPUTERNAME=OTTICI-HP
ComSpec=C:\Windows\system32\cmd.exe
C_EM64T_REDIST11=C:\Program Files (x86)\Common Files\Intel\Shared Files\cpp\
FPPUILang=en-US
FP_NO_HOST_CHECK=NO
Grande=C:\Program Files (x86)\EPSON_P2B\Printer Software\Status Monitor
HOMEDRIVE=C:
HOMEPATH=\Users\Parduz
KMP_DUPLICATE_LIB_OK=TRUE
LDRAWDIR=C:\Users\Public\Documents\LDraw
LOCALAPPDATA=C:\Users\Parduz\AppData\Local
LOGONSERVER=\\OTTICI-HP
NUMBER_OF_PROCESSORS=2
OnlineServices=Online Services
OOBEUILang=it-IT
OS=Windows_NT
Path=C:\SVILUPPO\Toolchains\MinGW 6.3.0-1\bin;C:\SVILUPPO\TOOLS\MinGW\bin\;C:\_Parduz_\_APPS_\ImageMagick-6.9.3-Q16;C:\Program Files (x86)\Common Files\Intel\Shared Files\cpp\BIN\INTEL64;C:\WINDOWS\MICROSOFT.NET\FRAMEWORK\V1.1.4322\;C:\PROGRAM FILES\COMMON FILES\MICROSOFT SHARED\WINDOWS LIVE;C:\PROGRAM FILES (X86)\COMMON FILES\MICROSOFT SHARED\WINDOWS LIVE;C:\Windows\SYSTEM32;C:\Windows;C:\Windows\SYSTEM32\WBEM;C:\Windows\SYSTEM32\WINDOWSPOWERSHELL\V1.0\;C:\PROGRAM FILES (X86)\INTEL\OPENCL SDK\2.0\BIN\X86;C:\PROGRAM FILES (X86)\INTEL\OPENCL SDK\2.0\BIN\X64;C:\PROGRAM FILES (X86)\BORLAND\COMPONENTS\TMS COMPONENT PACK\BPL\;C:\PROGRAM FILES (X86)\BORLAND\CALIBERRM SDK 2005 R2\LIB;C:\PROGRAM FILES (X86)\WINDOWS LIVE\SHARED;C:\Users\Parduz\Documents\Borland Studio Projects\Bpl
PATHEXT=.COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC
Platform=BPC
PROCESSOR_ARCHITECTURE=AMD64
PROCESSOR_IDENTIFIER=Intel64 Family 6 Model 42 Stepping 7, GenuineIntel
PROCESSOR_LEVEL=6
PROCESSOR_REVISION=2a07
ProgramData=C:\ProgramData
ProgramFiles=C:\Program Files
ProgramFiles(x86)=C:\Program Files (x86)
ProgramW6432=C:\Program Files
PROMPT=$P$G
PSModulePath=C:\Windows\system32\WindowsPowerShell\v1.0\Modules\
PUBLIC=C:\Users\Public
SystemDrive=C:
SystemRoot=C:\Windows
TEMP=C:\Users\Parduz\AppData\Local\Temp
TMP=C:\Users\Parduz\AppData\Local\Temp
USERDOMAIN=OTTICI-HP
USERNAME=Parduz
USERPROFILE=C:\Users\Parduz
VBOX_INSTALL_PATH=C:\Program Files\Oracle\VirtualBox\
windir=C:\Windows
windows_tracing_flags=3
WXWIN="C:\SVILUPPO\Toolchains\wxWidgets 3.0.3\Build Win Debug 6.3\..\"
Then i've tried to build the wxWidgets using:

mingw32-make -f ../build/msw/makefile.gcc SHELL=CMD.exe SHARED=0 MONOLITHIC=0 BUILD=debug UNICODE=1

but it can't find the "config.gcc" file... so i'm guessing i don't know how to build in a directory different from /build/msw...

QUESTIONS (finally :) )
  1. I know how to build the libraries in different folders using the MSYS shell and "configure", but how can i do this using MinGW-Make?
  2. How to make sure that all the wx component / libraries are build? (the app is still in early stages, i don't know if i'll need XML or what else)
  3. (if someone already know it) How should i set then Codeblock options to have it compile using one of the two folders? (i mean: should it search in my "custom" build folders or in the "main" wxWidgets one?
Thanks
ONEEYEMAN
Part Of The Furniture
Part Of The Furniture
Posts: 7459
Joined: Sat Apr 16, 2005 7:22 am
Location: USA, Ukraine

Re: Win7:How to build with different Gcc versions and use them?

Post by ONEEYEMAN »

Hi,
I think you are overcomplicating things. ;-)

Why not install VirtualBox and then create 2 virtual machines with 2 different Debian installs - one for each BBB.
Then you won't need anything - you will have 2 completely independent dev environment for each BBB and will be able to compile independently for every single board.

I think that VM are perfect solution for all of your issues.

Thank you.
User avatar
Parduz
I live to help wx-kind
I live to help wx-kind
Posts: 188
Joined: Fri Jan 30, 2015 1:48 pm
Location: Bologna, Italy

Re: Win7:How to build with different Gcc versions and use them?

Post by Parduz »

I don't see how installing and maintaing two virtual systems could be less complicated than building the widgets with two different compilers and let them coexist.... unless the latter being so damn hard to make your option the better one :)

More seriously, I'm a "windows man" forced to work with Linux... i'm pretty fast on debugging and doing whatever i want on Win, and a crippled sloth on doing anything on linux. So, as long i can debug on win, I have no issues on launching the BBBs compile when i go home and start the app the morning after.

Then there's a lot of things related to app maintenance, passing the developement to the young one, what the Boss wants etc.

Really, I'd like to know how to do what i planned if this is feasible.
User avatar
doublemax
Moderator
Moderator
Posts: 19114
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: Win7:How to build with different Gcc versions and use them?

Post by doublemax »

I don't use Linux, but i think building for Linux on Windows is much more difficult than the other way around. Because you need to have the linux header files and development libraries on the Windows machine.

https://stackoverflow.com/questions/476 ... ux/4770417
Doesn't sound simple.
Use the source, Luke!
ONEEYEMAN
Part Of The Furniture
Part Of The Furniture
Posts: 7459
Joined: Sat Apr 16, 2005 7:22 am
Location: USA, Ukraine

Re: Win7:How to build with different Gcc versions and use them?

Post by ONEEYEMAN »

Hi,
Parduz wrote: I don't see how installing and maintaing two virtual systems could be less complicated than building the widgets with two different compilers and let them coexist.... unless the latter being so damn hard to make your option the better one :)
It is harder. There is a question on switching between 2 different compiler settings, using 2 completely different set of headers/libraries and then properly selecting the appropriate compilation flag.
Usually the compiler selection is done thru the $PATH variable, which means you will continuously need to update the environment.

I'd say that installing 2 Debian VM will be much easier and simpler. ;-) Besides it will be a good learning curve.
Parduz wrote: More seriously, I'm a "windows man" forced to work with Linux... i'm pretty fast on debugging and doing whatever i want on Win, and a crippled sloth on doing anything on linux. So, as long i can debug on win, I have no issues on launching the BBBs compile when i go home and start the app the morning after.
You will get more in the long run if you go my route. You will have a better understanding of *nix and how to work there. You will see that maintaining *nix distro is not hard - just install the OS, install the compiler then grab the wx, compile it and compile the app. That it! You are done. You may wat to install GDB (*nix debuigger) and CodeBlocks/CodeLite (depending what you would like to use as the IDE, but that is all there is to do.

Besides if the app is targeting Linux only - you better have a real Linux system at hand to see what might go wrong in real life. Remember Windows and Linux use different set of classes/features in wxWidgets realm.
Parduz wrote: Then there's a lot of things related to app maintenance, passing the developement to the young one, what the Boss wants etc.

Really, I'd like to know how to do what i planned if this is feasible.
[/quote]

Giving the youngster the dev environment will definitely be easier. Just grab the VMs and copy them over to the new machine. All he will need to do is compile the app inside each. No learning whatsoever about switching compilers and how to properly work it out.

Thank you.
User avatar
xaviou
Super wx Problem Solver
Super wx Problem Solver
Posts: 437
Joined: Mon Aug 21, 2006 3:18 pm
Location: Annecy - France
Contact:

Re: Win7:How to build with different Gcc versions and use them?

Post by xaviou »

Hi.

If you want to make differents builds, you can use the "CFG' parameter on the command line.

It will result in differents "lib" sub-folders.

For example :

Code: Select all

mingw32-make -f makefile.gcc SHARED=0 MONOLITHIC=0 BUILD=debug CFG=xyz
This will place the libs file in %WXWIN%\lib\gcc_libxyz\....

And you can specify the value of the CFG parameter when using Code::Blocks project wizard (or adjust the include and libs path of an existing project).

Regards
Xav'
My wxWidgets stuff web page : X@v's wxStuff
User avatar
Parduz
I live to help wx-kind
I live to help wx-kind
Posts: 188
Joined: Fri Jan 30, 2015 1:48 pm
Location: Bologna, Italy

Re: Win7:How to build with different Gcc versions and use them?

Post by Parduz »

xaviou wrote: If you want to make differents builds, you can use the "CFG' parameter on the command line.
Thanks!
I've googled a lot to find if and what the "option" to do this was, and never find it....
what should i've looked for?

Anyway: tried it, i got an error :(
This is what i've done:

First clean:

Code: Select all

mingw32-make -f makefile.gcc clean
mingw32-make -f makefile.gcc CFG=MinGW630 clean
Then build:

Code: Select all

mingw32-make -f makefile.gcc CXXFLAGS="-std=gnu++11" USE_XRC=1 SHARED=0 MONOLITHIC=0 BUILD=debug CFG=MinGW630
This is the error:

Code: Select all

gcc -c -o gcc_mswudMinGW630\wxtiff_tif_win32.o -g -O0 -mthreads  -DHAVE_W32API_H -DNDEBUG -I..\..\src\zlib -I..\..\src\jpeg -I..\..\src\tiff\libtiff   -MTgcc_mswudMinGW630\wxtiff_tif_win32.o -MFgcc_ms
wudMinGW630\wxtiff_tif_win32.o.d -MD -MP ../../src/tiff/libtiff/tif_win32.c
In file included from ../../src/tiff/libtiff/tiffio.h:257:0,
                 from ../../src/tiff/libtiff/tiffiop.h:59,
                 from ../../src/tiff/libtiff/tif_win32.c:30:
c:\sviluppo\toolchains\mingw 6.3.0-1\include\stdio.h:345:12: error: expected '=', ',', ';', 'asm' or '__attribute__' before '__mingw__snprintf'
 extern int __mingw_stdio_redirect__(snprintf)(char*, size_t, const char*, ...);
            ^
makefile.gcc:5942: recipe for target 'gcc_mswudMinGW630\wxtiff_tif_win32.o' failed
mingw32-make: *** [gcc_mswudMinGW630\wxtiff_tif_win32.o] Error 1
User avatar
xaviou
Super wx Problem Solver
Super wx Problem Solver
Posts: 437
Joined: Mon Aug 21, 2006 3:18 pm
Location: Annecy - France
Contact:

Re: Win7:How to build with different Gcc versions and use them?

Post by xaviou »

Hi

I don't think the error you get comes from the CFG part.

The fact that you've added CFG=MinGW630 to your command line will just create specific folders for the intermediate build files (in the 'build/msw" sub directory) and for the resulting build files (in your case, they will be placed in "lib/gcc_libMinGW630" instead of the classic "lib/gcc_lib folder).

2 things you can do to speed-up your build(s) (these thing won't solve the problem you've mentionned in your previous post but you'll be able to make more tests if needed) :
First, launch your build command line wit the "setup_h" build target to initialize correctly the build :

Code: Select all

mingw32-make -f makefile.gcc setup_h CXXFLAGS="-std=gnu++11" USE_XRC=1 SHARED=0 MONOLITHIC=0 BUILD=debug CFG=MinGW630
Then, you can launch a "multi-job" command line :

Code: Select all

mingw32-make -f makefile.gcc -j4 CXXFLAGS="-std=gnu++11" USE_XRC=1 SHARED=0 MONOLITHIC=0 BUILD=debug CFG=MinGW630
The first command will create the sub directories needed for the build, and make the needed copy of "setup.h".
The second line will launch the build with 4 parallels processes.

But as I said, this won't solve the build problem.

I just remeber a tiem where MinGW didn't love the install paths with spaces (as it seems you've done).

Regards
Xav'
My wxWidgets stuff web page : X@v's wxStuff
ONEEYEMAN
Part Of The Furniture
Part Of The Furniture
Posts: 7459
Joined: Sat Apr 16, 2005 7:22 am
Location: USA, Ukraine

Re: Win7:How to build with different Gcc versions and use them?

Post by ONEEYEMAN »

Hi,
In addition to what Xaviou suggested you should make sure you are running the compiler version you intend to run.
Usually it is selected by the $PATH environment variable (whichever is first in the chain wins) or you can probably use the full path to the compiler' bin folder when you invoke it.

You can try to create 2 different batch files with the appropriate commands and use them in order to compile the library and your own code.
Also keep in mind that you will need 2 different targets inside your IDE (C::B) which will call this batch file and compile your target.

Thank you.
User avatar
Parduz
I live to help wx-kind
I live to help wx-kind
Posts: 188
Joined: Fri Jan 30, 2015 1:48 pm
Location: Bologna, Italy

Re: Win7:How to build with different Gcc versions and use them?

Post by Parduz »

xaviou wrote:I don't think the error you get comes from the CFG part.
Me neither. Sorry if i gave that impression. The CFG part worked and so I was reporting what happened :)

As a proof of it, the MinGW 4.9.3 built the libraries without any problem, given the same exact command with just the PATH variable changed (and CFG=MinGW491)

So, it is either a bug in the MinGW 6.3.0 stdio file (it had no problem compiling the linux sources in the BBB, dunno if this matters) or something in the wx sources that "mess" that #define....? Could it be possible?
Another courious thing is that using MSYS (from the MinGW 6.3.0) and configure worked (but i was'nt able to compile the samples, and then the HD crashed so i should try to replicate that steps)
xaviou wrote: 2 things you can do to speed-up your build(s) (these thing won't solve the problem you've mentionned in your previous post but you'll be able to make more tests if needed) :
First, launch your build command line wit the "setup_h" build target to initialize correctly the build :

Code: Select all

mingw32-make -f makefile.gcc setup_h CXXFLAGS="-std=gnu++11" USE_XRC=1 SHARED=0 MONOLITHIC=0 BUILD=debug CFG=MinGW630
Then, you can launch a "multi-job" command line :

Code: Select all

mingw32-make -f makefile.gcc -j4 CXXFLAGS="-std=gnu++11" USE_XRC=1 SHARED=0 MONOLITHIC=0 BUILD=debug CFG=MinGW630
The first command will create the sub directories needed for the build, and make the needed copy of "setup.h".
The second line will launch the build with 4 parallels processes.
Thanks a lot for this, both the suggestions and the explanations. I'll try it.
xaviou wrote: I just remeber a tiem where MinGW didn't love the install paths with spaces (as it seems you've done).
I can try also this, even if the older version (4.9.2) is able to build the libraries.
ONEEYEMAN wrote: In addition to what Xaviou suggested you should make sure you are running the compiler version you intend to run.
Usually it is selected by the $PATH environment variable (whichever is first in the chain wins) or you can probably use the full path to the compiler' bin folder when you invoke it.
You can try to create 2 different batch files with the appropriate commands and use them in order to compile the library and your own code.
Yep, this is exactly what i have. The BATCH code is in my first post (just for one version, the other changes just for the PATH setting)
ONEEYEMAN wrote: Also keep in mind that you will need 2 different targets inside your IDE (C::B) which will call this batch file and compile your target.
Working on it, to try the libraries build with the 4.9.2.
ONEEYEMAN
Part Of The Furniture
Part Of The Furniture
Posts: 7459
Joined: Sat Apr 16, 2005 7:22 am
Location: USA, Ukraine

Re: Win7:How to build with different Gcc versions and use them?

Post by ONEEYEMAN »

Hi,
You can try reporting this to the wx-dev ML as well as to the tiff maintainers.
In the meantime if you software will not use TIFF format, you can explicitly disable it using compile time option and see if there will be no issues during the compilation of the wx library itself.

Thank you.
stahta01
Ultimate wxWidgets Guru
Ultimate wxWidgets Guru
Posts: 548
Joined: Fri Nov 03, 2006 2:00 pm

Re: Win7:How to build with different Gcc versions and use them?

Post by stahta01 »

Link to my sh file used to build wxWidgets with different compilers.

https://github.com/stahta01/cb_misc/blo ... monolib.sh

I use COMPILER_VERSION/VENDOR instead of the suggested CFG.

Tim S.

Code: Select all

export PATH=/C/GreenApps32/mingw32-TDM-gcc-6.4.0-2/bin:$PATH

# echo $PATH

export _COMPILER_VERSION=640TDM

# echo $_COMPILER_VERSION

cd build/msw || exit 3

mingw32-make -f makefile.gcc \
  CFG=mono \
  VENDOR=$_COMPILER_VERSION \
  COMPILER_VERSION=$_COMPILER_VERSION \
  CXXFLAGS=-std=gnu++11 \
  MONOLITHIC=1 SHARED=1 UNICODE=1 BUILD=debug

mingw32-make -f makefile.gcc \
  CFG=mono \
  VENDOR=$_COMPILER_VERSION \
  COMPILER_VERSION=$_COMPILER_VERSION \
  CXXFLAGS=-std=gnu++11 \
  MONOLITHIC=1 SHARED=1 UNICODE=1 BUILD=release
User avatar
Parduz
I live to help wx-kind
I live to help wx-kind
Posts: 188
Joined: Fri Jan 30, 2015 1:48 pm
Location: Bologna, Italy

Re: Win7:How to build with different Gcc versions and use them?

Post by Parduz »

Sorry for the delay, got sidetracked by some other emergency ...

Today i've been back to this again, and finally compiled my app with the libraries built with MinGW4.9.2.
Some of the obstacle i've found (i plan to recap everything in a final post for everyone might be interested in the future):
- Yep, no spaces in the folder name. The compiler was not able to find my own sources 'cause the path was broken 'cause the space in it.
- I needed a LOT of googling before learning that the libraries for the linker needs to be inserted in a specific order, and then needed some time to figure out what that order was. Maybe my google-fu is the worst in the universe, but i'd liked something more than an answer on StackOverflow to get the idea of what was happening...


ONEEYEMAN wrote: You can try reporting this to the wx-dev ML as well as to the tiff maintainers.
I'd like to do it, if i were able to understand where to go :oops:
What (or where) wx-dev ML is?


ONEEYEMAN wrote:In the meantime if you software will not use TIFF format, you can explicitly disable it using compile time option and see if there will be no issues during the compilation of the wx library itself.
I'm sorry.... how could i do that? I see that the USE_GUI enables a lot of libraries, the TIFF one as well... how can i exlude just that one?

stahta01 wrote:Link to my sh file used to build wxWidgets with different compilers.
https://github.com/stahta01/cb_misc/blo ... monolib.sh
I use COMPILER_VERSION/VENDOR instead of the suggested CFG.
Interesting. I'll try it. Thanks
User avatar
Parduz
I live to help wx-kind
I live to help wx-kind
Posts: 188
Joined: Fri Jan 30, 2015 1:48 pm
Location: Bologna, Italy

Re: Win7:How to build with different Gcc versions and use them?

Post by Parduz »

Parduz wrote:i got an error :(
This is what i've done:

First clean:

Code: Select all

mingw32-make -f makefile.gcc clean
mingw32-make -f makefile.gcc CFG=MinGW630 clean
Then build:

Code: Select all

mingw32-make -f makefile.gcc CXXFLAGS="-std=gnu++11" USE_XRC=1 SHARED=0 MONOLITHIC=0 BUILD=debug CFG=MinGW630
This is the error:

Code: Select all

gcc -c -o gcc_mswudMinGW630\wxtiff_tif_win32.o -g -O0 -mthreads  -DHAVE_W32API_H -DNDEBUG -I..\..\src\zlib -I..\..\src\jpeg -I..\..\src\tiff\libtiff   -MTgcc_mswudMinGW630\wxtiff_tif_win32.o -MFgcc_ms
wudMinGW630\wxtiff_tif_win32.o.d -MD -MP ../../src/tiff/libtiff/tif_win32.c
In file included from ../../src/tiff/libtiff/tiffio.h:257:0,
                 from ../../src/tiff/libtiff/tiffiop.h:59,
                 from ../../src/tiff/libtiff/tif_win32.c:30:
c:\sviluppo\toolchains\mingw 6.3.0-1\include\stdio.h:345:12: error: expected '=', ',', ';', 'asm' or '__attribute__' before '__mingw__snprintf'
 extern int __mingw_stdio_redirect__(snprintf)(char*, size_t, const char*, ...);
            ^
makefile.gcc:5942: recipe for target 'gcc_mswudMinGW630\wxtiff_tif_win32.o' failed
mingw32-make: *** [gcc_mswudMinGW630\wxtiff_tif_win32.o] Error 1
Got this problem again, stumbled in my own question, but this time i've found a solution, which I write here for anyone needing it again:

From this Answer at StackOverflow i've followed the links, finding this ticked and so this fix.

______________________________________________________________________________________________

About my original question, this is how it is for me:

I have one batch file which "sets" the environment for each specific compiler (or better, specific MinGW version) and opens the command prompt with these settings "active":
SelectMinGW6330.bat

Code: Select all

@echo off
set PATH=..\..\Toolchains\MinGW-6.3.0-1\bin;%PATH%
set Comp_Version=MinGW630
set WXWIN="%~dp0..\"
cd "%~dp0"
"C:\Windows\system32\cmd.exe"
from here i check if everything is ok (usually just a gcc -v command) and then i launch the wx build.

Using code::blocks, i can set different "compilers", each one using his own Environment variables. Then I can configure the build options in the project using each different "compiler" as a different "target".

So yes, it is possible and it works.

Thanks to all
Post Reply