Home
Community
Manuals
Login or Signup

Guide how to set up MinGW for BlitzMax

BlitzMax Forums/BlitzMax Programming/Guide how to set up MinGW for BlitzMax

ziggy1+ years ago #1
MinGW

MinGW is a tool that allows BlitzMax to compile external (C, C++, Objective C) code on Windows. MinGW is not needed for Mac OS X and Linux, as BlitzMax uses a similar tool that comes pre-installed with those operating systems.

You will need MinGW if you wish to build a module that uses external code. Even though many of the first-party BlitzMax modules use external code, you do not need MinGW to use these modules as they are provided pre-built. If you wish to change these modules by editing the code, you will need MinGW.

Also, some third-party modules (such as minib3d), use C++ and are not provided pre-built. So you will need MinGW to use these modules.


STEP 1 INSTALLING MINGW ON DISK
This guide asumes you have downloaded and installed MinGW in the folder c:\mingw. If you haven't downloaded and installed MinGW, please download it from here http://www.blide.org/backup/MinGW.rar and unrar it to c:\MinGW or any other valid location (not in program files).
You can also get the MinGW from its sourceforge location, but you'll have to pass through a setup utility.


STEP 2 FOR BLIDE USERS
Open BLIde and go to "Tools / Configure MinGW compiler". There, all you have to do is tell BLIde wich is the MinGW location at disk (usually "C:\MinGW")
That's all, and no systems variables are modified in the process!!


STEP 2 FOR MAXIDE/MAXIDE CE OR OTHER IDE USERS
This is the step-by-step process:

ANY WINDOWS OS:
1.- Click the start button, right click on 'My Computer' on XP or 'System' on Vista and seven. Then click on 'Properties'. Select the 'Advanced Properties Tab' and at the bottom you will see the 'Environment Variables' button. Click that.
It should open up a new window with two boxes named 'User Variables for blah' and 'System Variables'.

2.- Click 'New' for User Variables and in the 'Variable Name' box type MinGW. In the 'Variable Value' Box enter the path to the MinGW installation ie C:\MinGW. Then click OK.

3.- In the 'System Variables' box, scroll down until you see the variables Path. Click on it and click the edit button. In the 'Variable Value' box, move your curser to the end of text, ADD A SEMI COLON, and put the path to your MinGW\bin directory. eg, c:\MinGW\Bin. Click ok and ok again and if you are using windows XP, you are ready to go, if you're using Vista or Win7, you have to make one little additional step:

VISTA ONLY:
4.- The same way you have added the environment variable called MinGW (step 2), you should create an environment variable named GCC_EXEC_PREFIX and set it to c:\MinGWIt seems it is not required any more.


After this, you're ready to go!



Last edited 1+ years ago


Brucey1+ years ago #2
What, no MinGW guide for Mac or Linux users Ziggy? :-)


Armitage 19821+ years ago #3
Hoooo, Very nice new feature !
Really appreciated.
Maybe one day I will only have to install Blide to already finishing 25% of any project :)

Thanks Ziggy.


ziggy1+ years ago #4
What, no MinGW guide for Mac or Linux users Ziggy?

Oh yes! Sorry:

That's the MinGW guide for Mac and Linux:

1.- Install windows

2.- Follow the avobe guide.

:D


Munch1+ years ago #5
Can we use MinGW on Mac and Linux now?


Zeke1+ years ago #6
how about adding those env variables to MaxIDE? i mean that ide should check from settings mingw folder.. if it not exists then check from default C:\MinGW and if it is not there ide should ask "is mingw installed?" and if it is then enter mingw install folder..
then just use:
putenv_("MinGW=C:\MinGW")
putenv_("GCC_EXEC_PREFIX=C:\MinGW")


when ide start(^^ folders of course from settings) and no need to manually modify/add environment vars.

hmm..
MinGW has been confirmed working in Windows Vista Business! Thanks to Aaron Giles' Solving the Windows Vista Build Issues for the solution. In summary, the MinGW folder must be "a directory immediately off the root of your hard disk for some reason. So c:\mingw works fine, but c:\tools\mingw won’t." (You can use mklink to symbolic-link the folder, which also works). Secondly, set the GCC_EXEC_PREFIX environment variable to the MinGW root folder. Finally, add %GCC_EXEC_PREFIX%\libexec\gcc\mingw32\3.4.5 and %GCC_EXEC_PREFIX%\lib\bin to the PATH environment variable.

^^ this is from http://wiki.codeblocks.org/index.php?title=MinGW_installation

so maybe if we also add:
Local path:String=GetEnv_("PATH")
putenv_("PATH="+path+";C:\MinGW\libexec\gcc\mingw32\3.4.5;C:\MinGW\lib\bin")


then no need to even copy files..

just tested and this works.. Install latest MINGW 5.1.6, then installed blitzmax (with ^^ above additions) and you can build modules without settings env vars..

But this *fix* need to be added official maxide source before this works.


plash1+ years ago #7
Can we use MinGW on Mac and Linux now?
You're definitely trolling.
Are you trolling? I hope you're trolling.

P.S. We can.


ziggy1+ years ago #8
Can we use MinGW on Mac and Linux now?
No, you can't. MinGW is the windows port of the GNU compiler and utils.
EDIT: I mean to produce native apps to the platform MinGW is being run. For Linux the regular GNU compilers are your friends


Brucey1+ years ago #9
Can we use MinGW on Mac and Linux now?

You can of course use it to cross-compile on Mac and Linux to create Windows binaries.


Armitage 19821+ years ago #10
You can of course use it to cross-compile on Mac and Linux to create Windows binaries.

Yeah but I'm still waiting a guide to compile Mac and Linux binaries under Windows ;-)

What !?
Not possible ? Pffwaa !?

...Would buy a software to achieve this easily...


Munch1+ years ago #11
You're definitely trolling.
Are you trolling? I hope you're trolling.

I wasn't trolling. Ok, maybe I was.

You can of course use it to cross-compile on Mac and Linux to create Windows binaries.

This is what I was thinking of. I see you can run MinGW through Wine and Darwine. Personally I consider it proper programming to build and test on the target platform.

Thanks for sharing your howto here, ziggy. I've lost count the amount of times people ask how to do this.


Brucey1+ years ago #12
Personally I consider it proper programming to build and test on the target platform.

Ah yes, just as they do on Android, iPhone, the DS, PSP, 360 and PS3 :-)


ziggy1+ years ago #13
As long as the target platform can have a proper gui, keyboard and editor, you are not forced to do it "as they do on Android, iPhone, the DS, PSP, 360 and PS3" But, you know... there are lots of kinds of people!


Munch1+ years ago #14
Ah yes, just as they do on Android, iPhone, the DS, PSP, 360 and PS3 :-)

Touche. Shown up again.


Grisu1+ years ago #15
A guide how to set up gcc 4.x would be nice too. ;)


zeb1+ years ago #16
Sorry, but the above link doesn't work, and I saw that in the mingw page the classic automated exe installer has dissapeared... How I can install mingw now? :O

SOLVED!!
I downloaded the exe installer 5.1.6 from another web page, and the installer works OK. Mingw installed and modules compiled!!!

Regards and thank you for the guide!!


cr1+ years ago #17
.


Grisu1+ years ago #18
@cr: This worked for me: http://www.blitzbasic.com/Community/posts.php?topic=91390


okee1+ years ago #19
SOLVED!!
I downloaded the exe installer 5.1.6 from another web page, and the installer works OK. Mingw installed and modules compiled!!!


zeb can you post the link to that page.


Grisu1+ years ago #20
http://sourceforge.net/projects/mingw/ ?


Dwapook1+ years ago #21
Eh.. it doesn't appear to be on there! I'm having trouble finding it too!


GfK1+ years ago #22
What's the crack with MinGW now??

I'm trying to install it here, but whatever it deems to be the "latest version" (and in fact the only version I can find to download), actually installs itself as "Mingw-get 0.1 alpha 5". WTF?

Further, there is NO "MinGW Base Tools" or "g++ compiler" options any more.

I let it install compilers for C/C++, but as I expected, Blitzmax just throws an eppy when I try to build mods.

Clues?


Ole JR1+ years ago #23
Someone posted this on their SourceForge page
Used to be quite useful for creating a build enviroment on windows. Has now become intensly user hostile, due to a sudden change in project management.
The new structure has split things up into a package managed system. However, they have not actually got a working package manager yet.
Rather than maintain their old install path, they insist on asking the user to manually download the many different files, to unpack and install them by hand.
Including running their install scripts when needed.


Someone else linked to another package http://tdm-gcc.tdragon.net/download

Tested the On-Demand Installer from there, and it seem to work.
Atleast I got it to build default pub & brl without any fuzz on WinXP.

Last edited 1+ years ago


GfK1+ years ago #24
Thanks - just tried that and got exactly the same error as before:
Building Modules
Compiling:blitz_app.c
In file included from C:/BlitzMax/mod/brl.mod/blitz.mod/blitz.h:5:0,
from C:/BlitzMax/mod/brl.mod/blitz.mod/blitz_app.c:2:
/mingw/lib/gcc/mingw32/4.5.1/../../../../include/stdio.h:26:20: fatal error: stddef.h: No such file or directory
compilation terminated.
Build Error: failed to compile C:/BlitzMax/mod/brl.mod/blitz.mod/blitz_app.c
Process complete



Amon1+ years ago #25
@GfK

Did you move/copy the files cc1.exe , cc1plus.exe and collect2.exe from C:\MinGW\libexec\gcc\mingw32\4.5.0 to C:\MinGW\bin?

I don't know why it behaved like that but copying those files in to the bin folder seemed to get rid of a similar error I got. I was also then able to build modules.

Last edited 1+ years ago


skidracer1+ years ago #26
Goodness what a mess. Perhaps it's time that BlitzMax moved to LLVM for it's native Windows tool chain.


ziggy1+ years ago #27
Taking into account the license of MinGW, couldn't BRL just distribute the good old installer, or just provide a binary version (install-free) of the whole package, here? this would solve all this mess


GfK1+ years ago #28
MinGW has always been a bit of a car crash, but this??! Its like they'd already hit rock-bottom in software standards, then started digging.

I have no idea what LLVM is, but if it works, I'll have some.


skidracer1+ years ago #29
That does seem better option as LLVM doesn't seem to be that mature on Windows yet.


GfK1+ years ago #30
Thought I'd cracked it.

Added the following user env vars:

C_INCLUDE_PATH >> C:\MinGW\include;C:\MinGW\lib\gcc\mingw32\4.5.0\include
CPLUS_INCLUDE_PATH >> C:\MinGW\include;C:\MinGW\lib\gcc\mingw32\4.5.0\include

It was all going great, until it got to reflection.cpp:

Compiling:reflection.cpp
C:/BlitzMax/mod/brl.mod/reflection.mod/reflection.cpp:3:19: fatal error: cstdarg: No such file or directory
compilation terminated.
Build Error: failed to compile C:/BlitzMax/mod/brl.mod/reflection.mod/reflection.cpp
Process complete


*shoots self*


Dabhand1+ years ago #31
I'm not on Vista, but on XP, I downloaded the newest version of MinGW, selected 'G++' (EDIT: C++ Compiler and dev toolkit), edited the enviro variables, built modules... Jobs a good'un!

Think though, do you have to move a few files on Vista/Win7... Theres a thread (Sticky'd) by the Sib in the Module tweaks section that shows which files to move!

EDIT: http://blitzbasic.com/Community/posts.php?topic=72892#823441

Not sure exactly why we have 2 sticky topics on the subject really, out of date ones too! :P Mmmmm

Dabz

Last edited 1+ years ago

Last edited 1+ years ago


GfK1+ years ago #32
I downloaded the latest version from the MinGW website (its called mingw-get-inst-20101030.exe). It doesn't have any G++ option! There's also no MinGW Base Tools option.


Dabhand1+ years ago #33
C++ compiler and dev toolkit!

Basically, I've been fannying on with that much compiler shite my heads spinning!

Dabz

Last edited 1+ years ago


GfK1+ years ago #34
I'm 99.9% certain those are the options I installed - I'll try again...

[edit] Yep, same errors.

Last edited 1+ years ago


GfK1+ years ago #35
* Dances his "nailed the b*tch" dance *

Removed the GC_EXEC_PREFIX environment variable and its all compiling like a good 'un!

Apparently this env var is no longer required on Windows 7 (maybe vista too).

[edit] Oh, and as Dabz pointed out, the components to install are NOW called "C++ compiler" and "MinGW Developer Toolkit".

Last edited 1+ years ago


okee1+ years ago #36
On xp sp3 i still couldn't get it to work after everything was set up correctly, only doing what xlsior said got it to work

http://www.blitzbasic.com/Community/posts.php?topic=91805#1045000


ziggy1+ years ago #37
To make things easier, here you can download a install-free binary distribution I've uploaded: http://www.blide.org/backup/MinGW.rar It works and contains requiered packages. Just unrar it to c:\MinGW Also updated the guide at the top of the post.

Last edited 1+ years ago


InvisibleKid1+ years ago #38
ziggy, curious why ver 5.1.3 and not ver 5.1.6...

i've been using 5.1.6 for quite sometime now, is 5.1.3 better?


ziggy1+ years ago #39
5.1.3 is the one officially suggested by Mark. That's the only reason. I would update it to 5.1.6 if it was officially supported.


Dabhand1+ years ago #40

but you'll have to pass through a setup utility that does not work properly.



Worked a charm here!?! Mmmm

Dabz

Last edited 1+ years ago


John G1+ years ago #41
Bought a new HP mini-tower PC, dual AMD with Win 7.
Downloaded BlitzMax 1.4.1 plus MaxGUI 1.4.1. Both fine.
Couldn't Build Modules like odd2D, etc.
Downloaded MinGW from Ziggy's site (4 posts up).
Downloaded 7-ZIP to open .rar file.
Used Ziggy's recently edited directions (top).
I'm now cross platform. Thanks guys!


FreakForFreedom1+ years ago #42
'Had the same problem as John G.
Ziggy's MinGW-Backup and post did the trick!
Thank you! :)


JoshK1+ years ago #43
If you install MinGW in "Program Files" I think you have to do this:
C:\Progra~1\MinGW


Russell1+ years ago #44
I have all of the following set in 'environment variables':
User: MinGW -> C:\MinGW
(Notice NO GCC_EXEC_PREFIX here)

System: Added ';C:MinGW\bin;C:MinGW\lib;C:MinGW\include' to the end of the PATH variable

All modules compile (brl,pub,koriolis,wx,maxmod2,bah->freeimage and bah->sfxr)

ALL example programs compile and run EXCEPT for the freeimage ones, which produce tons of 'undefined reference to `_Unwind_Resume'' errors. These errors occur with every version of minGW I have installed, including the very latest, even after compiling all modules to get all the modules 'on the same page'. Freeimage is the only module so far that just will not work no matter what I try! Grrr!!!! Even the humungous wx module and its example programs work with no problems!

Anyone have any ideas?

Russell


therevills1+ years ago #45
Hi All,

I'm trying to get MinGW to work on my work PC (Windows 7 32bit).

I have copied Ziggy's MinGW.rar and extracted in my c drive, so it is at c:\MinGW

I have added the MinGW to the environment variables and added ;c:\MinGW\bin; to the PATH variable.

When I type in g++ --version in the console I get the following:

H:\>g++ --version
g++ (GCC) 3.4.5 (mingw-vista special r3)
Copyright (C) 2004 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.


But when I compile my game I get these errors:

Compiling:fullaccess.cpp
D:/Users/revills/Dropbox/CodeMax/project/Include/fullaccess.cpp:5:21: windows.h: No such file or directory
D:/Users/revills/Dropbox/CodeMax/project/Include/fullaccess.cpp:6:20: aclapi.h: No such file or directory
D:/Users/revills/Dropbox/CodeMax/project/Include/fullaccess.cpp:7:18: sddl.h: No such file or directory
D:/Users/revills/Dropbox/CodeMax/project/Include/fullaccess.cpp:9: error: `LPCTSTR' was not declared in this scope
D:/Users/revills/Dropbox/CodeMax/project/Include/fullaccess.cpp:9: error: `LPTSTR' was not declared in this scope
D:/Users/revills/Dropbox/CodeMax/project/Include/fullaccess.cpp:9: error: initializer expression list treated as compound expression
D:/Users/revills/Dropbox/CodeMax/project/Include/fullaccess.cpp:11: error: `LPCTSTR' was not declared in this scope
D:/Users/revills/Dropbox/CodeMax/project/Include/fullaccess.cpp:12: error: expected `,' or `;' before '{' token
D:/Users/revills/Dropbox/CodeMax/project/Include/fullaccess.cpp:19: error: redefinition of `bool GiveDirectoryFullAccessToGroup'
D:/Users/revills/Dropbox/CodeMax/project/Include/fullaccess.cpp:9: error: `bool GiveDirectoryFullAccessToGroup' previously defined here
D:/Users/revills/Dropbox/CodeMax/project/Include/fullaccess.cpp:19: error: `LPCTSTR' was not declared in this scope
D:/Users/revills/Dropbox/CodeMax/project/Include/fullaccess.cpp:19: error: `LPTSTR' was not declared in this scope
Build Error: failed to compile D:/Users/revills/Dropbox/CodeMax/project/Include/fullaccess.cpp


I've been trying quite a few things in this thread but I still get these errors!!!

Any ideas?
Thanks!

[Edit]
Nevermind... a reboot fixed it - d'oh!

Last edited 1+ years ago


Htbaa1+ years ago #46
It probably would've been enough to restart your IDE :-)


JoshK1+ years ago #47
Not only is the GCC_EXEC_PREFIX env var no longer needed, it will actually cause C++ compiling to fail.


visionastral1+ years ago #48
like JoshK said:

DON'T MAKE THE GCC_EXEC_PREFIX VARIABLE!
It will not compile the modules.
(at least on W7 64)


Ben Hurr1+ years ago #49
I like how the newest MinGW installers don't have g++ or toolkit options anymore. >: (

It's starting to seem like Blitz needs to get together it's own minGW distribution at this rate.


GfK1+ years ago #50
This thread probably shouldn't be stickied any more since the information, while great at one time, is now hopelessly out of date and much of it does not apply.

MinGW is a pain in the ass and no mistake.


ziggy1+ years ago #51
@Gfk: AFAIK, It's updated. I've been editing the main post so it is up to date. if there's anything that requires changing, please let me know.


GfK1+ years ago #52
Well, to be fair, I think most of the problems I have (the -ldsound one, etc) are probably just down to MaxMod2.

MaxMod2 hasn't been updated for years now and is probably dead in the water, but what it does (streaming audio from a raw OGG file loaded into memory) is invaluable in reducing both load-time and resources when music is needed. To this day I do not understand why Blitzmax could never stream music natively.

Sadly, I'm not aware of anything that does an equal job and does not require me to empty out my wallet.


Derron1+ years ago #53
MaxMod2 needs some small changes to work as intended (for me on linux). Depending on the OS I use different maxmod2-sources (created lite-versions for win32 and linux as I did not need flac and dumb, included the changed lines provided somewhere here in the forums).
But on windows not all mingw-versions did work flawless, needed some tries to get it work.

@streaming - I claim to remember that I had a streaming audio solution "ripped" of maxmod some months ago, but it did not work flawless on win32 AND linux, so I just patched maxmod2 until it fit my needs (pulseaudio support in the right order so simultaneous audio output of multiple applications is possible).

@mingw: I also would like a more current but official "supported" mingw - for all platforms so brucey could code using that and would make it easier for us to use his wonders.

bye
Ron


bonito1+ years ago #54
I think mingw is more or less a dead project.
There is a win64-mingw branch of it .. maybe use this or try to compile in cygwin. At least the compiler in cygwin is much more current than mingw which is years old.


xlsior1+ years ago #55
I think mingw is more or less a dead project.
There is a win64-mingw branch of it .


The stock blitzmax won't compile with the 64-bit MinGW version, although Brucey is working on some tweaks to make it work -- See some of his recent posts on the forum.


Schlowski1+ years ago #56
After fiddling more than 2 hours with my system to get rid of this:

Building Modules
Compiling:blitz_app.c
In file included from C:/BlitzMax/mod/brl.mod/blitz.mod/blitz.h:5:0,
from C:/BlitzMax/mod/brl.mod/blitz.mod/blitz_app.c:2:
/mingw/lib/gcc/mingw32/4.5.1/../../../../include/stdio.h:26:20: fatal error: stddef.h: No such file or directory
compilation terminated.
Build Error: failed to compile C:/BlitzMax/mod/brl.mod/blitz.mod/blitz_app.c
Process complete


I finally found the cause for this issue: I have a FreePascal 2.6.4 installed on my system which sets the system path to ...;d:\Programme\FPC\2.6.4\bin\i386-win32

Unfortunately this path overrules the Blide settings for MingW so when building the modules the wrong compiler is executed, resulting in all these ugly errors. After removing FreePascal from the path everything works "out-of-the-box" with the preinstalled MingW.rar from Ziggy. This was a really nasty side effect...


Blitz BASIC Founders Fund