Can you use a later build of MinGW64 compiler for Blitzmax NG?

Started by SC-Dan37, July 26, 2017, 23:33:13

Previous topic - Next topic

SC-Dan37

I've been playing with this for a couple of days and can get BlitzNG and mods to compile using the latest MinGW64 compiler (7.10) but the executable will not run with a 0xc000007b error. Has anyone tried to compile with something other than TDM GCC 5.1? I ask because that build is getting old now.

Thanks

TomToad

Did you try rebuilding all modules after updating MinGW?
------------------------------------------------
8 rabbits equals 1 rabbyte.

GW

Quote from: SC-Dan37 on July 26, 2017, 23:33:13
executable will not run with a 0xc000007b error.

I get this error a lot too. 
NG has a problem with attaching to 32bit dll's at runtime for 64bit applications.  I don't know how to solve it myself, but it prevents me from NG as much as i'd like.
Try opening your compiled program in dependency walker (http://www.dependencywalker.com/) and you will might see references to 32bit dlls. 

SC-Dan37

TomToad: Yes I did recompile all mods.

GW: Thanks. I did look at the program with Dependency Walker (had searched the error) and could not see a 32 bit library referenced, but I'll double check it.

SC-Dan37

You were right, GW, Dependency Walker shows 2 32bit libraries linked: LIBGCC_S_SJLJ-1.DLL and LIBSTDC++-6.DLL. Will do some searching on the net...

SC-Dan37

I installed the MinGW 7.1.0 i686 libraries and recompiled all mods and a test program without issue. Trying to compile a program using MinGW 7.1.0 x64 libraries will compile the mods in 32bit but will come up with lots of linker errors when trying to compile a program, so yeah, there is some incompatibilities with the 64 bit version of MinGW. Do you know if Brucey is on this forum or have you submitted a bug ticket in GitHub for this?

Rooster

Yeah Brucey's on here. The easiest way to get his attention here would probably be a PM.

SC-Dan37

Had some more ideas and tried it again and have successfully compiled programs in 32 bit and 64 bit in Windows 10. Here is what I did.


  • Installed MinGW32 7.1.0 i686, then installed MinGW64 7.1.0 x64 in a different directory. For example: 32 bit MinGW in D:\mingw\i686\mingw32, and 64 bit MinGW in D:\mingw\x64\mingw64. (When installing using the Mingw-installer, I pointed to D:\mingw\i686. The installer adds mingw32. Same thing on the 64bit build.)
  • Set the MINGW environment variable to the MinGW32 folder. I put mine in my user variable section, not the system.
  • Added the MinGW32 folder/bin to the windows path system environment variable. For example the 32bit mingw install: D:\mingw\i686\mingw32\bin
  • Installed Blitzmax from GitHub following the instructions
  • Using Blitzmax compiled NG bcc and bmk from GitHub and put them in the correct directory (from Brucey's instructions).
  • Put brl, pub, and maxgui modules in correct directory and compiled using NG's bmk. For example: opening a command prompt and navigating to my Blitzmax NG bin directory I would type: bmk -a -g x86 -h brl to compile the brl modules for 32bit. (-h is optional for multithreaded builds). Do the same for pub and maxgui mods.
  • Compiled maxIde cleanly using bmk -a -g x86 -h -t gui d:\path\to\maxide.bmx.

Now for 64 bit:

  • Change the MINGW environment variable to the directory where the MinGW64 directory is. For example, mine would be d:\mingw\x64\mingw64
  • Change the path environment variable to the MinGW64/bin directory. For example: D:\mingw\x64\mingw64\bin
  • Using bmk recompile brl, pub, and maxgui mods: in Blitzmax NG bin directory on command prompt: bmk -a -g x64 -h brl (again -h is optional for multithreading). Do the same for pub and maxgui
  • Using bmk comile maxIde using bmk makeapp -a -g x64 -h -t gui d:\path\to\maxide.bmx. Again -h is optional.

Hope this helps. Will experiment a bit further to see if I can cross compile using the mingw64 to 32bit, but at least with this build each one is achievable. Interested if others have the same results...

Henri

Hi,

nice and informatic guide. I remember that NG's bmk searches 32-bit libraries in <bmx-folder>\MinGW32\ by default, so if you create <bmx-folder>\MinGW64 folder for 64-bit libraries, your program would link fine ?

-Henri
- Got 01100011 problems, but the bit ain't 00000001

SC-Dan37


TomToad

I remember that Brucey had created two default folders for MinGW,  one for 64 bit builds and one for 32 bit builds.  I think it was simply <ng-install>/MinGW32 and <ng-install>/MinGW64, but I am not sure.  Tried searching for the thread on wasted.nz, but I can't find it.  Maybe looking through the bmk source will help locate the proper directories.

Edit: Found it, from the bmk,bmx
' 3.17 25/02/2017 - Support for single-target MinGW32 distros (eg. MinGW-w64), with paths MinGW32x86 and MinGW32x64.
------------------------------------------------
8 rabbits equals 1 rabbyte.

xlsior

Interesting, will give that a shot.

Question: The MinGW online downloader/installer gives several choices:

threads: posix/Win32  --> Which one?
Exception: Dwarf / sjlj / Seh -> I'm assuming we need sjlj there?

markcwm

If you follow what TDM GCC uses you should be okay
http://tdm-gcc.tdragon.net/quirks

So for threads Posix and exceptions SJLJ in 32-bit and SEH in 64-bit


SC-Dan37

Thanks, Tom! Naming the folders MinGW32x86 and MinGW32x64 works just fine. BMK will compile, for example, maxide cleaningly.

However, the executable will not run without copying 3 dll files from the mingw bin directory (at least for 64 bit): libgcc_s_seh-1.dll, libstdc++-6.dll, and libwinpthread-1.dll. Anyone else having this issue?

edit: but I can compile a program in MaxIDE and run it without issue. Now I'm confused...