Using mingw as a cpp target on 64-bit Windows

367 views
Skip to first unread message

Jacob Watkins

unread,
Jul 17, 2014, 2:53:42 AM7/17/14
to haxe...@googlegroups.com
I'm trying to figure out how to set-up mingw to work with hxcpp. Haxe version 3.1.3, MingW version from set-up, with the mingw+MSys it wanted.

Getting down to it, haxe wants Visual Studio, even though I have mingw installed. Is there a way I can specify the default cpp compiler without mucking around with things? I've looked all over the place and all I can find is compiling haxe itself with mingw, or a few references to how hxcpp has support for mingw, but they are all from 2012 or 2009.

I've tried to adapt:

https://groups.google.com/forum/#!msg/haxelang/dj0l8BRxBIY/hc32MonbazQJ <https://groups.google.com/forum/#%21msg/haxelang/dj0l8BRxBIY/hc32MonbazQJ>

When I add the -D mingw to my hxml (which I wouldn't have to do in the first place if mingw was detected right) I get about errors of no disk in the drive... even if I try my mingw path as its root or the bin folder.

Further searching finds if the drive letter i: exists, mingw throws errors, re-lettering the drive solves that.

THEN I have to define my Windows version as XP because AttachConsole isn't defined when the system version isn't found (it compiles to Win98, good lord). In order to do THAT I had to add:

#define WINVER _WIN32_WINNT_WINXP
to \lib\hxcpp\version\include\hxcpp.h

Which will obviously cause the problem to come back compiling for 64-bit too. On that note, hxcpp always tries to compile -m32, but I can't seem to find a way to pass the static flags. These are required for mingw to not dynamically link the gcc libraries when a 64-bit version is installed. The flags I found here:

https://groups.google.com/forum/#!topic/haxelang/mPiWF4VJS28 <https://groups.google.com/forum/#%21topic/haxelang/mPiWF4VJS28>

Overall I'm having a hard time getting haxe compiling because there's very sparse documentation on actual settings. I had to search Google to find where .hxcpp_config.xml and even basic setting up of hxml files. There wasn't even a refernce to the manual to find this information. These pages:

http://old.haxe.org/doc/start/cpp
http://gamehaxe.com/2011/04/05/nme-from-scratch/
Are almost useless because there are a million things that seem to go wrong trying to set up mingw.

Putting the required gcc DLLs in my program directory (whether I compiled with -cpp cpp or -cpp bin, if there is a difference) makes a Hello World run correctly. A console is still opened, the program is 32-bit, the libraries are dynamically linked, and i still have to edit an hxcpp header to get it to compile on a platform XP or later.

If I could get any assistance in resolving this, and if the information was added to the documentation or haxe and hxcpp were updated to make this easier, it would be greatly appreciated. I am sure many others would also appreciate this, as it might also make building windows targets from a Linux environment easier.

Hugh

unread,
Jul 18, 2014, 1:56:38 AM7/18/14
to haxe...@googlegroups.com

Hi

I don' think it is that far off from working - it is just a matter of addressing the issues one by one.

* A console is still opened,

  There is code to use "WinMain" instead of "main" via the HX_WIN_MAIN define.  The relevant sections need to be ported from msvc-toolchain to mingw-toolchain.  You can then #ifdef out the AttachConsole code, or dynamically link the code, as suggested in the post you link.

* the program is 32-bit,

   32 bit by far the preferred architecture on windows.  I have never seen any example where 64 bits is superior in any measurable way. 

* the libraries are dynamically linked,

   Some magic need to be put into mingw-toolchain.xml - not sure what, but likely only a flag

* and i still have to edit an hxcpp header to get it to compile on a platform XP or later.

   A pull request will solve this issue for everyone for ever.

You think you can default to mingw on your box for all projects using .hxcpp_config.xml:

<section id="vars">
  <set name="HXCPP_MINGW" value="1" />


Hugh

.


Reply all
Reply to author
Forward
0 new messages