maxmod2 doesn't compile with MinGW GCC 4.4

BlitzMax Forums/BlitzMax Programming/maxmod2 doesn't compile with MinGW GCC 4.4

jpavel(Posted 2009) [#1]
I've submitted an issue on the Google Code page, but I'm cross posting here just in case REDi follows these forums, but doesn't check on the project page that much.

-------------
maxmod2 doesn't compile with MinGW GCC 4.4

What steps will reproduce the problem?
1. Use current MinGW GCC version, 4.4
2. Try to build maxmod2


What is the expected output? What do you see instead?

Expected a clean compile, got compile errors in file.cpp; once I added
stdio.h to maxmod2.h, it compiled, but later on caused various STL link
errors.

What version of the product are you using? On what operating system?

Maxmod2 1.07 on Windows


Brucey(Posted 2009) [#2]
maxmod2 doesn't compile with MinGW GCC 4.4

I'd beware using a version of MinGW that isn't yet officially supported by BlitzMax.


REDi(Posted 2009) [#3]
Hi jpavel

Interesting I'll take a look when I've got some time, but why do you need to use GCC 4.4?


Brucey(Posted 2009) [#4]
why do you need to use GCC 4.4?

It's the current version of MinGW.

4.x is actually much better than the version we are using at the moment.


skidracer(Posted 2009) [#5]
Last time I tried upgrading MingW I failed. You need to flush all the 3.x binaries and libs from the blitzmax folders, link with extra files which will compile blitzmax programs, that just segfault...


The topic title infers blitzmax runs with 4.4 just fine so maybe it is possible.


REDi(Posted 2009) [#6]
Well I just installed all the GCC 4.4 stuff (which was a pain in the arse) and all modules compiled fine and seem to be working here, including MaxMod2.

typing "gcc -v" in command prompt reveals this...

Using built-in specs.
Target: mingw32
Configured with: ../gcc-4.4.0/configure --enable-languages=c,ada,c++,fortran,jav
a,objc,obj-c++ --disable-sjlj-exceptions --enable-shared --enable-libgcj --enabl
e-libgomp --with-dwarf2 --disable-win32-registry --enable-libstdcxx-debug --enab
le-version-specific-runtime-libs --prefix=/mingw --with-gmp=/mingw/src/gmp/root
--with-mpfr=/mingw/src/mpfr/root --build=mingw32
Thread model: win32
gcc version 4.4.0 (GCC)



So I assume it is actually using GCC 4.4

*EDIT* OSG seems to be linking a bit quicker now with GCC 4.4 and the latest ld and ar utils.

*EDIT AGAIN* Sorry my mistake, replacing the contents of the BlitzMax/libs folder with new libs breaks everything :(


jpavel(Posted 2009) [#7]
Thanks for looking into it, REDi.

Hmm, on all the machines that I've tried with 4.4, I get the same errors. The standard BlitzMax modules rebuild fine.

Here's the result from my compile attempt:

C:\>echo %MINGW%
C:\MinGW

C:\>C:\MinGW\bin\gcc -v
Using built-in specs. Target: mingw32
Configured with: ../gcc-4.4.0/configure --enable-languages=c,ada,c++,fortran,java,objc,obj-c++ 
--disable-sjlj-exceptions --enable-shared --enable-libgcj --enable-libgomp --with-dwarf2 --disable-win32-registry
 --enable-libstdcxx-debug --enable-version-specific-runtime-libs --prefix=/mingw --with-gmp=/mingw/src/gmp/root 
--with-mpfr=/mingw/src/mpfr/root --build=mingw32
Thread model: win32
gcc version 4.4.0 (GCC)

C:\>bmk makemods -a maxmod2
Compiling:music.cpp
Compiling:file.cpp
C:/BlitzMax/mod/maxmod2.mod/maxmod2.mod/code/file.cpp: In member function 'virtual void cfile::Close()':
C:/BlitzMax/mod/maxmod2.mod/maxmod2.mod/code/file.cpp:6: error: 'fclose' was not declared in this scope
C:/BlitzMax/mod/maxmod2.mod/maxmod2.mod/code/file.cpp: In member function 'virtual int cfile::Eof()':
C:/BlitzMax/mod/maxmod2.mod/maxmod2.mod/code/file.cpp:7: error: 'feof' was not declared in this scope
C:/BlitzMax/mod/maxmod2.mod/maxmod2.mod/code/file.cpp: In member function 'virtual long int cfile::Position()':
C:/BlitzMax/mod/maxmod2.mod/maxmod2.mod/code/file.cpp:9: error: 'ftell' was not declared in this scope
etc...




xlsior(Posted 2009) [#8]
Which BMK are you using?

The standard one, or Brucey's BMK NG?

When I try to recompile maxmod2 using Brucey's BMK NG, it errors out on me:


C:/Code/BlitzMax/mod/maxmod2.mod/dumb.mod/dumb/src/core/atexit.c:22:18: dumb.h: No such file or directory
C:/Code/BlitzMax/mod/maxmod2.mod/dumb.mod/dumb/src/core/atexit.c:23:27: internal/dumb.h: No such file or directory
Build Error: failed to compile (1) C:/Code/BlitzMax/mod/maxmod2.mod/dumb.mod/dum
b/src/core/atexit.c

Build Error: failed to compile (1) C:/Code/BlitzMax/mod/maxmod2.mod/dumb.mod/dumb/src/core/atexit.c



Recompiling it with the standard BMK works OK.


REDi(Posted 2009) [#9]
Yay, I've finally managed to reproduce your compile error, and fixed as you suggested with stdio and it does now compile. But I'm getting loads of undefined reference to '_Unwind_*' linking errors for everything I build not just MaxMod2.

Is this the same linking problems you mentioned?

I'm thinking this might be a problem with libstdc++/libsupc++ or libgcc.


REDi(Posted 2009) [#10]
oh, I didn't know about that one xlsior


REDi(Posted 2009) [#11]
xlsior, this may fix your BMK NG problem

dumb.bmx

I can't test ATM, because I've buggered up MinGW with GCC 4.4 ;)


jpavel(Posted 2009) [#12]

But I'm getting loads of undefined reference to '_Unwind_*' linking errors for everything I build not just MaxMod2.

Is this the same linking problems you mentioned?



Those are the errors I'm getting, but for me it was only for maxmod2... or it could be that the IDE was using the GCC 3.4.5 install that I had somewhere, and so built the BRL modules properly.


REDi(Posted 2009) [#13]
Here's what I get from building digesteroids (from the samples and doesn't use maxmod2)



so it seems BlitzMax isn't ready for GCC 4.4, or maybe my GCC 4.4 is buggered :D


xlsior(Posted 2009) [#14]
xlsior, this may fix your BMK NG problem


Looks like it did -- thanks!


Brucey(Posted 2009) [#15]
so it seems BlitzMax isn't ready for GCC 4.4, or maybe GCC 4.4 is buggered

Well, to be honest, I've had BlitzMax running on MinGW with 4.x for a while now ;-)
But because some of the third-party libraries that I've modularised are quite old, not everything of mine will build - without fixing those libraries. So I've never really mentioned the whole 4.x thing here before...

:-)


REDi(Posted 2009) [#16]
I've had BlitzMax running on MinGW with 4.x for a while now ;-)

Cool! out of interest mate, what's the solution to these stdc/supc link errors? Have you noticed much improvement using GCC 4.4?


popcade(Posted 2010) [#17]
Well, what version of MinGW is BlitzMax using anyway?

5.1.4 is the lowest version available atm, or what version should I use to avoid break the BlitzMax?


Grisu(Posted 2010) [#18]
I'm also interested in upgrading from 3.4.5 to 4.4.x. Is there an automated installer for it?


REDi(Posted 2010) [#19]
Is there an automated installer for it?

Not officially AFAIK, but some unofficial...

http://tdragon.net/recentgcc/

I haven't tried with this, but I think the SJLJ build would probably do it.


xlsior(Posted 2010) [#20]
I just tried to install gcc 4.4.1, and had no problems recompiling maxmod2 using Brucey's bmk ng myself... Nor any of the other modules.

(When updating gcc, also make sure to copy ar.exe and ld.exe from the mingw\bin folder to blitzmax\bin)


xlsior(Posted 2010) [#21]
.


Grisu(Posted 2010) [#22]
What package do I need from the site? 4.4.1-tdm-2, SJLJ Unwinding, package "g++" and "core"?

Never installed that by hand. The exe installer doesn't let me continue.


xlsior(Posted 2010) [#23]
4.4.1-tdm-2, SJLJ Unwinding, package "g++" and "core"?


I picked core, g++, objc and objc++, figured to add the last two just in case.

Ended up unzipping them into the existing MinGW directory structure (after backing it up), overwriting a ton of stuff in the process.

"gcc -v" at the command line now returns this:
gcc version 4.4.1 (TDM-2 mingw32)


Afterwards I was able to successfully re-compile all modules, including maxmod2, without errors.


Grisu(Posted 2010) [#24]
Thanks for the informations!

Can't recompile the modules (using normal bmx here.).
Any ideas?

"Compiling:blitz_app.c
gcc: CreateProcess: No such file or directory
Build Error: failed to compile C:/BlitzMax/mod/brl.mod/blitz.mod/blitz_app.c
Prozess abgeschlossen"

4.4.1 is installed. It is stated inside the ide and via gcc -v
Also I copied ar.exe and ld.exe from the mingw\bin folder to blitzmax\bin


I must have missed something on the way. :/

Apps compile fine though. - And much faster than before.


REDi(Posted 2010) [#25]
For anyone interested, here is an archive of MinGW32 GCC 4.4.1 (from the TDM/MinGW Installer 1.908.0)

Rename your original MinGW and lib folders first, so you can retrieve them later. I would also suggest using a separate install of blitzmax

http://maxmod.googlecode.com/files/MinGW.rar

and the replacement lib folder for BlitzMax

http://maxmod.googlecode.com/files/lib.rar

I also had to add
Import "-lstdc++"
Import "-lgcc"

to brl.blitz.bmx for some reason.

Rebuild All Modules and that should be it! (you may want to rebuild bmk also)

*EDIT* oh, and don't forget to update ar and ld ;P


Grisu(Posted 2010) [#26]
Thanks Redi. Did all steps and still get the strange error message:
"Compiling:blitz_app.c
gcc: CreateProcess: No such file or directory
Build Error: failed to compile C:/BlitzMax/mod/brl.mod/blitz.mod/blitz_app.c"

Do I need to use Brucey's bmk.exe or will the default one work?


Brucey(Posted 2010) [#27]
I also had to add ... to brl.blitz.bmx for some reason.

The problem is due to the fact that libs need to be linked in a slightly different order for 4.x.
I had this problem when cross-compiling too, so my BMK should already be set up to handle this.


Grisu(Posted 2010) [#28]
@Bruce:
When using your bmk I get this error. Don't know if this helps...
"C:/BlitzMax/lib/libgcc.a(unwind-sjlj.o): In function `_gthread_key_create':
c:\crossdev\b4.4.1-tdm-1\build-sjlj\mingw32\libgcc/../../../../gcc-4.4.1/libgcc/../gcc/gthr-win32.h:585: undefined reference to `__mingwthr_key_dtor'
C:/BlitzMax/lib/libgcc.a(gthr-win32.o): In function `_gthr_win32_key_create':
c:\crossdev\b4.4.1-tdm-1\build-sjlj\mingw32\libgcc/../../../../gcc-4.4.1/libgcc/../gcc/config/i386/gthr-win32.c:112: undefined reference to `__mingwthr_key_dtor'"


REDi(Posted 2010) [#29]
@Grisu

That's the error I get if I don't import libstdc++ and libgcc in blitz.bmx, I tried with BMK NG but that also gives me this problem, but adding the libs fixes it with both BMKs here.

You could try importing "-lgcc" at the top of the file you're trying to build.


Arowx(Posted 2010) [#30]
Are there any benefits to using gcc 4.4 over 3.x, e.g. optimisations, memory footprint, compile times?

Or is it worth spending a day on breaking my dev environment for, mid project?


xlsior(Posted 2010) [#31]
gcc 4.4 has a lot of internal optimizations which may result in speedups, but of course results will vary.

I'm seeing some slight differences in some of my programs, but nothing in others.


Grisu(Posted 2010) [#32]
Finally got it working... :o)



Hopefully GCC4 will be officially supported in the future.