MinGW for Beginners

BlitzMax Forums/BlitzMax Tutorials/MinGW for Beginners

markcw(Posted 2016) [#1]
Yes TomToad just wrote a pretty good guide HERE but I have a slightly different take on MinGW which hopefully is the easiest.

1. Legacy Bmx 1.50

As TomToad points out there are two ways to install legacy Bmx (that is the zip from this site). Either you get (a) Nuwen's MinGW with gcc 4.6.1 which is not available now so is hosted by TomToad or the same thing by Armitage HERE or TDM's 4.6.1 HERE (b) go for an update with TDM's MinGW with gcc 4.7.1 as shown by Brucey HERE. You can also use the bmk from Bmx NG for legacy or OS Bmx as explained HERE but I haven't tried this.

The nice thing about 4.6.1 is it's the easiest just run the installer or extractor, you don't have to run the batch file since legacy Bmx was compiled with 4.6.1 but you still have to create the environment var named MINGW with value "c:\mingw" and add "c:\mingw\bin;" to the ones in PATH (find it from Computer > System properties > Advanced system settings > Environment Variables). Also note you can't have more than one MinGW environment var path at a time, it just uses the first one it finds. I've not experienced any bugs with it and I recommend using TDM's 4.6.1 as it is official (tip: untick the checkbox in the installer).
Using TDM 4.7.1 is recommended by Brucey but you need to create a file named maybe "batchcopy.bat" put it in your Bmx folder then open cmd and type "cd ../../bmx" then just "batchcopy". You also need to check the two variables at the top are correct. After that check your environment vars are right (from Help > About MaxIDE) also include BMK_LD_OPTS then rebuild all modules from the IDE or in cmd "cd bin" and "bmk makemods -a".

2. OS Bmx 1.52

This is great as you get an update to legacy Bmx and you get to use any version of MinGW because you can now build bcc from source. The files in bin also should be built with the same version of MinGW you're using (or you may get fatal errors "undefined reference to blah"). I recommend using TDM 5.1.0 HERE 64 bit version, the 32 bit version also works but if you use the 64 bit version (which also supports 32 bit) you can use Bmx NG as well without having to change the environment vars every time you want to use the other version. Alternatively, since Bmx NG checks for a local "MinGW32" folder (in the Bmx folder) this allows you to use two different MinGW installs without having to change environment vars. Installing is made very easy with the install.bat it builds everything you don't even have to rebuild all modules just download it HERE extract to maybe "blitzmax-os", set the environment vars and in cmd type "cd _src\win32_x86" then run "install".

3. Bmx NG

This gives you access to 64 bit (x64, x86 is 32 bit) and supports other platforms RPi, Android, iOS and Web. There is a stable pre-compiled release HERE which only requires to build modules, the latest is currently v0.70 with MinGW GCC 5.1. If you want the latest beta/release candidate and are prepared a fairly complex install process (and unexpected errors) then follow these steps. Download bcc, bmk, maxide, brl.mod, pub.mod and maxgui.mod from HERE create a new folder "blitzmax-ng" and then inside more folders "bin", "src" and "mod" then extract bcc, bmk and maxide to src and brl/pub/maxgui to mod and remove "-master" from the names. Then copy MaxIDE.exe and all of bin files from legacy or OS Bmx to NG. At this point make sure the environment vars use a 64 bit TDM (some report 4.8.1 is less error-prone but I recommend 5.1.0 and bug report issues - some mods like wxMax require 5.1.0) now you can build bcc with "cd blitzmax-ng/bin" and "bmk makeapp -a -r -t console ../src/bcc/bcc.bmx" or use the IDE. Then build bmk and copy bcc.exe and bmk.exe to bin, bmk also needs two extra files in bin copied from src/bmk called core.bmk and make.bmk. Also, for faster compile times build bmk in threaded mode (bmk option -h). Now test bcc and bmk work by "bcc -v" and "bmk -v" which should show the version number. Then build all modules "bmk makemods -a" this builds x86 to get x64 you need to build modules again with "bmk makemods -a -g x64". Last to get the x64 compile option in the IDE build src/maxide/maxide.bmx and copy the exe to the main folder.


TomToad(Posted 2016) [#2]
the 32 bit version also works but if you use the 64 bit version (which also supports 32 bit) you can use Bmx NG as well without having to change the environment variables every time you want to use the other version.


Haven't used BMX-NG that much, but doesn't the NG compiler first look for a blitzmax-ng\MinGW\ folder and use that, only using the environment variables if the subdirectory doesn't exist? Then you could use 64 bit version for NG and 32 bit version for legacy.

Reason I ask is because I have had problems using the 64 bit version with legacy BM. Modules compile fine, but I get errors when trying to compile a program. Might be an error on my part, but uninstalling the 64 bit version and installing the 32 bit version fixed the problems. I might want to try using the NG version again and I would like to keep both versions of MinGW on my PC.


RustyKristi(Posted 2016) [#3]
thank you for this munch. I have Bmx and BMX-NG installed properly, but already forgot the steps that I did before. I'll try this one of these days.

4.8.1 worked for me with BMX and BMXNG


Brucey(Posted 2016) [#4]
NG will look for a local MinGW32 folder first, before querying the environment. This is the preferred configuration, as it keeps everything neatly self-contained.


markcw(Posted 2016) [#5]
I never used a local MinGW32 folder with Bmx NG but that would be really handy if your using legacy Bmx as it's bcc is limited to a maximum of 4.7.1, any higher and I got undefined reference errors.

I'm using OS Bmx with 5.1.0 64 and it builds apps fine. I actually did have a similar problem with 5.1.0 and I thought it wasn't going to work but I just forgot one of the steps, I used the wrong env var more than once and another time I forgot to rebuild mods.

I also forgot to mention using Brucey's modified bmk.


degac(Posted 2016) [#6]
Stupid question (maybe...)

If I'm using a 64bit OS (like Windows 10) I still must use TDM-GCC-4.7.1 (NOT TDM64-GCC-4.7.1.exe), right?
Of course I exclude BMX-NG.


Henri(Posted 2016) [#7]
As Mr.Garrison said there are no stupid questions :-)

In reference to Windows it doesn't matter which version OS you have. 64-bit MinGW is required to build 64-bit apps (applies to NG only) , but you can use 32-bit MinGW in 64-bit enviroment to build 32-bit apps. Allthough some of Brucey's modules like wx are built with 64-bit toolchain so using 32-bit MinGW might result to some errors.
TDM MinGW 64-bit has both 32-bit and 64-bit toolchain , but special BMK might be required to used (linker need to be told which version to use).

32-bit TDM version 4.7xx of might suffice to you, and it's a solid base to build special versions of Blitzmax tools like bcc and bmk if needed.

-Henri


markcw(Posted 2016) [#8]
As Henri says, you can use either 32 or 64 bit TDM MinGW since 64 will build 32, but it must be set up right (ie. bmk and bcc and lib should be built with the same MinGW as following mod or app).


degac(Posted 2016) [#9]
Thanks.
but it must be set up right (ie. bmk and bcc and lib should be built with the same MinGW as following mod or app). 

The fastest solution is to download the 64bit bcc/bmk/etc than trying to download/configure/compile them.
I mean, I must have a 32-bit chain to use Vanilla-Bmax, and then move/compile to 64bit... too much work :)


markcw(Posted 2016) [#10]
I mean, I must have a 32-bit chain to use Vanilla-Bmax, and then move/compile to 64bit... too much work

Not sure what you mean by Bmx Vanilla, I assume you mean Bmx Legacy/1.50. If you use that then you're tied to MinGW 4.6/4.7 because you can't rebuild bcc for a higher version (it breaks at 4.8). But you can drop into Bmx NG a subfolder named MinGW32 and it will work without any env var stuff.

I don't recommend using Bmx 1.50 now though as Bmx OS has extra fixes (like the pixmap leak) and it lets you rebuild bcc, removes the libs dependency and has an install script. So I'm using a single TDM 5.1.0 64bit for both OS and NG (needing only MINGW dir and PATH for bin env vars).


LT(Posted 2016) [#11]
.