Win32 BlitzMax with GCC 4.x - HowTo

BlitzMax Forums/Brucey's Modules/Win32 BlitzMax with GCC 4.x - HowTo

Brucey(Posted 2011) [#1]
People seem to have a lot of problems using a newer version of MinGW with BlitzMax on Windows. The main problem is that versions of MinGW which use the GCC version 4.x require that certain files installed with BlitzMax are replaced with new ones from the MinGW install.
There are also linking issues with bmk, because the order of some files need to be changed to work correctly with 4.x.

I've created a bundle of files which can be used to replace those in your default BlitzMax install. This should ease setting up BlitzMax to use GCC 4.x.

I recommend you use the TDM version of MinGW, since I have found it to be vastly more predictable to set up than the "official" MinGW.
The latest version of TDM that we can use with BlitzMax without too many issues is 4.7.1. Later versions are only available as a 64-bit deployment, and don't necessarily support compilation of 32-bit binaries.

The downloads for TDM MinGW 32-bit are available at : http://sourceforge.net/projects/tdm-gcc/files/TDM-GCC%20Installer/Previous/1.1006.0/

You should download and install the tdm-gcc-4.7.1-2.exe release, near the top of the list.

You will also need to run a batch-script to overwrite certain files in BlitzMax/bin and lib with the ones from MinGW that you have just downloaded.

Here's the source :
@echo off
@set dirMinGW=c:\mingw
@set minGWVersionString=4.7.1
@set dirBlitzmax=c:\coding\BlitzMax

copy %dirMinGW%\bin\ar.exe %dirBlitzmax%\bin /Y
copy %dirMinGW%\bin\ld.exe %dirBlitzmax%\bin /Y

for /f "delims=" %%i in ('dir %dirBlitzmax%\lib /b') do (
copy "%dirMinGW%\lib\%%i" "%dirBlitzmax%\lib\%%i" /z /y
copy "%dirMinGW%\lib\gcc\mingw32\%minGWVersionString%\%%i" "%dirBlitzmax%\lib\%%i" /z /y
)

You will need to change the paths to correspond with those where your files are located - That's those for dirMinGW, and dirBlitzmax.

-----------------------------------------------------

Install Procedure

1) Install MinGW in the usual place.
2) Make sure to add both the MINGW environment variable and add it's bin dir to the PATH - as per normal.
3) If you intend to use the official bmk (rather than my replacement), you will need to create a another environment variable with the following settings : BMK_LD_OPTS = -lmsvcrt -lgcc
(This is because of changes to the libs in later versions of MinGW.)
4) Install BlitzMax.
5) Create and run the script.
6) Rebuild All modules.

-----------------------------------------------------

I just did a full install as above, and everything appears to work as expected.
I also tested BaH.FreeImage, and the examples built and ran as expected.

Hope this helps a little

:o)

Last edited 2011


Russell(Posted 2011) [#2]
Brucey, thanks a million for posting this. I was REALLY getting frustrated... (Maybe this should be stickied and/or combined with Mark's How to on module compilation?)

Anyway, I'm at work now, but wil give this a go as soon as I get home!

Thanks again.
Russell


Brucey(Posted 2011) [#3]
Maybe I should add a disclaimer? : "It worked for me, but your mileage may vary"... ;-)


Russell(Posted 2011) [#4]
Worked for me too, this time!
You are a life (and hair) saver, Brucey!

The only issues I ran into so far are:
- wx.mod/wxrarinputstream.mod complains about not finding a file called 'new.h' which is not part of any of the newer minGW installations apparently, but I found it in an older minGW setup and put it in minGW/include folder.

- The CEGUI example, widgetgalore.bmx gives an error about not finding d3dx9.dll (missing from system), but switching to the OpenGL driver (BaH.CEGUIOpenGL) instead fixes it (and I hear that installing the newest DirectX redistributable fixes the problem also).

- CEGUI requires Regex.mod, it seems (the pcre files). No big deal. Compiled and ran fine after I copied it (regex.mod) to bah.mod.

Otherwise, it all looks good!

Thanks again!
Russell


Russell(Posted 2011) [#5]
Whoops, it seems I need unicows because when I try to run any MaxGUI programs, for example the 'redrawgadget.bmx' example, I get:

Linking:.redrawgadget.debug.exe
c:/mingw/bin/../lib/gcc/mingw32/4.5.2/../../../../mingw32/bin/ld.exe: cannot find -lunicows
collect2: ld returned 1 exit status
Build Error: Failed to link C:/BlitzMax/docs/html/Modules/MaxGUI/MaxGUI/.redrawgadget.debug.exe
Process complete


I searched my system and the only unicows program I found was in an Adobe installation called 'unicows.dll'. Is that it?

Other than MaxGUI programs and the above mentioned minor glitches, everything seems to be working!

Any ideas about the unicows thing, though?
Russell

[EDIT: Actually, I found a file in the BlitzMax/lib folder (copied from your file bundle 'lib' folder) called 'libunicows.a'. It's there, so I don't know why it can't find it. On a possibly related note, I have in my path, in addition to the C:\MinGW\bin folder, I also have C:BlitzMax\bin. Could this be interferring? {I have it just before the MinGW\bin entry}]

[EDIT 2: It seems MaxGUI is the only one having problems now (The unicows thing). None of the MaxGUI examples will compile without that error so far. But honestly, I can live without it. Still, it would be nice to know what's up with it.]

Last edited 2011

Last edited 2011


xlsior(Posted 2011) [#6]
What version of Windows are you running?

On win95/98 you explicitly need unicows.dll for things to work, on newer versions of windows that shouldn't be necessary.


Brucey(Posted 2011) [#7]
If anything, unicows should be a runtime check and only loaded if required on those specific versions of the OS. Not impossible, as that is how the openal module works.

Worked for me too, this time!

Glad you got it working at last :-)


Russell(Posted 2011) [#8]
I have Windows 7 x64, so I would imagine that it would be included, right? I've been able to compile and run MaxGUI programs in the past, but that may have been under Windows XP before I upgraded to Windows 7. (Been a while since I've had any need to use MaxGUI, so I can't remember.)

Is the 'lunicows.a' file in the BlitzMax/libs folder the one it is looking for, do you think? Should I put the BlitzMax/lib folder in the PATH just to be sure?

Anyone else running Win7 x64, with BMax 1.42 and the latest minGW able to compile and run MaxGUI programs? Or getting the same error as me?

Anyway, it's no big deal (I'll be using wx.mod most likely from now on anyway for any GUI apps I may need). Thanks again, Brucey, and everyone else who offered help.

Russell


Russell(Posted 2011) [#9]
I have a second, default, installation of BlitzMax and it compiles MaxGUI fine, so I'll just use that for the rare times that I need something using MaxGUI.

Since it works in the default setup, does that mean there's something in the newer minGW files that were copied to BlitzMax/bin and /lib that it doesn't agree with?

Thanks for all your help, and thanks for stickying this as well!

Russell


Nigel Brown(Posted 2011) [#10]
Thank you Brucey for your help with this, unfortunately after 3 days of compiling I am still no closer to achieving a successful link of my program. How difficult can this be all the modules re-build without any errors. Still get the _Unwind_Resume errors at the linking stage of my program, it uses wx and some of the BaH modules.


Linking:main.debug.exe
C:/BlitzMax/mod/wx.mod/wx.mod/../lib/win32/libwxmsw29u_xrc.a(xrclib_xmlres.o):xmlres.cpp:(.text+0x23c): undefined reference to `_Unwind_Resume'
C:/BlitzMax/mod/wx.mod/wx.mod/../lib/win32/libwxmsw29u_xrc.a(xrclib_xmlres.o):xmlres.cpp:(.text+0x491): undefined reference to `_Unwind_Resume'
C:/BlitzMax/mod/wx.mod/wx.mod/../lib/win32/libwxmsw29u_xrc.a(xrclib_xmlres.o):xmlres.cpp:(.text+0x77b): undefined reference to `_Unwind_Resume'
C:/BlitzMax/mod/wx.mod/wx.mod/../lib/win32/libwxmsw29u_xrc.a(xrclib_xmlres.o):xmlres.cpp:(.text+0x939): undefined reference to `_Unwind_Resume'
C:/BlitzMax/mod/wx.mod/wx.mod/../lib/win32/libwxmsw29u_xrc.a(xrclib_xmlres.o):xmlres.cpp:(.text+0x95f): undefined reference to `_Unwind_Resume'
C:/BlitzMax/mod/wx.mod/wx.mod/../lib/win32/libwxmsw29u_xrc.a(xrclib_xmlres.o):xmlres.cpp:(.text+0xbac): more undefined references to `_Unwind_Resume' follow


jkrankie(Posted 2011) [#11]
Mostly this works ok. LibcurlSSL.mod doesn't build though, complaining it's missing the libssh2.h file.

Libcurlssh does build if i don't update the lib and bin folder with the files you provided however.

Cheers
Charlie

Last edited 2011


Brucey(Posted 2011) [#12]
libssh2 is in another module (bah.libssh2) . Strange that it builds okay when you use different binaries...


Henri(Posted 2011) [#13]
Link to the bundle does not seem to work.


Brucey(Posted 2011) [#14]
I've now migrated to a new host... hopefully everything will be back to normal soon (within 24 hrs as the DNS caches are refreshed).

At least my email is working again :-)


Grisu(Posted 2015) [#15]
Hey Brucey,

could you please add these findings here to your installation instructions?
http://www.blitzbasic.com/Community/post.php?topic=104339&post=1263586

The extra system variable mentioned fixed my compiling problems under Win 8.1 (64 Bit) with MinGW 4.8.1 (with your BMX module tweaks installed).

Thanks!


Danny(Posted 2015) [#16]
Just a warning to people that might read and want to try this - I believe this is heavily out-of-date again!!!

That's is, I've spend two days trying to get the OFX + bah.freeimage modules to compile - on a win7/64 machine. with NO luck, whatsoever. Whilst all other modules (incl many others) work fine.
I tried all the different hacks suggested in other threads; I hope others have more luck..

meh
PS. I also need minGW to program my Arduino - but I'm pretty sure that's gone to hell now as well...


Danny(Posted 2015) [#17]
OK --- I'm running Win7 /64bit, I followed the instructions, but still can't create the modules for OFX..

@Brucey: Is it normal that HALF the files don't get found/copied using your batch-file?! When using "tdm-gcc-4.7.1-2.exe", the files DO exist in the folder "MinGW\lib", but NOT in the folder: "MinGW\lib\gcc\mingw32\4.7.1" -as used by the 2nd copy command, in the for loop.

Then, ALL modules build fine (Bah, Pub, etc) - including Bah.FreeImage "build" without problem - BUT the freeImage examples don't work: "Can't find interface for module 'bah.freeimage'" (note: I'm using freeimage_1_07_src.zip)

And the above, prevents me from building OFX.CORE:
Compile Error: Can't find interface for module 'bah.freeimage'
[C:/Dropbox/BlitzMax/mod/ofx.mod/core.mod/source.bmx;28;1]
  Build Error: failed to compile C:/Dropbox/BlitzMax/mod/ofx.mod/core.mod/source.bmx


WHY?! What am I doing wrong, this time?! :)

Thanks in advance for any help!!! I'm dying to get cracking with OpenCV - even bought a new WebCam last weekend for it, but I'm dead in the water, at the moment :(

Danny.


Danny(Posted 2015) [#18]
After / whilst rebuilding ALL modules again, using:
C:\Dropbox\blitzmax\bin\bmk makemods -a brl.mod
C:\Dropbox\blitzmax\bin\bmk makemods -a -h brl.mod
C:\Dropbox\blitzmax\bin\bmk makemods -a
C:\Dropbox\blitzmax\bin\bmk makemods -a -h

I get this one:
Building Modules
Archiving:bass.debug.mt.win32.x86.a
Archiving:fmod.debug.mt.win32.x86.a
ar: creating C:/Dropbox/BlitzMax/mod/BaH.mod/bass.mod/bass.debug.mt.win32.x86.a
ar: creating C:/Dropbox/BlitzMax/mod/BaH.mod/fmod.mod/fmod.debug.mt.win32.x86.a
Archiving:FreeImage.debug.mt.win32.x86.a
ar: creating C:/Dropbox/BlitzMax/mod/BaH.mod/FreeImage.mod/FreeImage.debug.mt.win32.x86.a
ar: unable to rename 'C:/Dropbox/BlitzMax/mod/BaH.mod/FreeImage.mod/FreeImage.debug.mt.win32.x86.a'; reason: File exists
Build Error: Failed to create archive C:/Dropbox/BlitzMax/mod/BaH.mod/FreeImage.mod/FreeImage.debug.mt.win32.x86.a
Process complete



Brucey(Posted 2015) [#19]
I've updated the original post with a new step 3, to set an environment variable for users of the official bmk.
(although I'd recommend trying bmk_ng, as it supports parallel builds, which can greatly speed up the build process)