haXe 2.04 with C++ support
Today haXe 2.04 was released.
Thanks to the hard work of Hugh Sanderson, haXe now have support for the C++ platform.
It then mean that you can compile any haXe program directly to C++, and get the performances of the one of the world fastest languages ! C++ support open also a lot of new possibilities for haXe targets, including huge progress on running haXe on iPhone
In order to use the C++ platform, you will have to use the -cpp target, but before that you need to install the hxcpp library that contains all things needed to compile. This is easily done by running the following command :
haxelib install hxcpp
Now, you can simply write a small haXe program :
class Test { static function main() { trace("Hello World !"); } }
And compile it with :
haxe -cpp out -main Test
This will give you a file out/Test.exe that when run will simply display Hello World.
Easy, isn't it ?
In order to go further, you can use the APIs that have been made accessible from haXe/C++, they are fully listed on the haXe API pages.
It's of course possible to interoperate with other C++ programs, but these details will be soon documented.
Actually, C++ is the 6th platform supported by haXe, since there is already :
- Flash (for Flash Player versions <=8)
- Flash9 (AVM2, for Flash Player versions >= 9)
- Javascript
- Neko
- PHP
- ... and now C++
Which will be next one ? ;)

Maybe objective-c for iphone? :)
Python and Java should be interesting :)
Oh, maybe not a new language but a RIA framework in haxe?
So that we can build a single haxe project and compile into a complete RIA with both server side and client side.
.Net may be :D
>> zproxy
Iphone can execute c++ code natively (they compile to the same think) so objc isnt really needed. Thats how iphone i already supported.
I thought this was already available (iphone)
http://gamehaxe.com/2009/05/22/haxe-on-iphone-simulator/
A wonderful job! Thanks to everyone who worked on this, I'm really excited about this release!
Hi, I am using VC7's cl.exe, here's the error:
hxObject.h(129) : error C2785: “double hxMod(TL,TR)” and “int hxMod(int,int)” have different return types
python and ruby =)
Great news indeed!
Does someone else have the error "no compiler defined" on osx?
What am I missing?
Cheers!
Draetsch it sounds like you don't have xcode / dev tools installed
just grab the iphone sdk and you should be good to go
Thanks for your answer.
I have XCode installed. Version 3 and GCC 4. Is that the problem?
How abount using CPP API from Flash or using Flash API from CPP
add Python i think in will bee great
how abount compile with MinGW
Wow finally we have a new release with new features!
The latest version of haxe seems to break the current version of swhx:
/usr/local/lib/haxe/lib/swhx/1,2,0/swhx/Plugin.hx:93: characters 14-31 : haxe.#Http has no field request
(Because request has been renamed requestUrl, according to haxe's change log - making that name change in Plugin.hx seems to fix it.)
Time for a new release of swhx, I guess?
@Draetsch: I got the "no compiler defined" error on Mac OS X too. I was able to solve that by doing 'export OSTYPE="darwin"' before trying to compile, but I still couldn't get it to work, so far.
It might be better to use a different OSTYPE and add to the haxecpp configuration files: It looks like the only Mac configurations 'haxe -cpp' understands are for the iPhone SDK. I'm using gcc 3 on OS X 10.3.9 and apparently it's not compatible: haxe generates the c++ source fine, but it seems haxecpp and gcc 3 don't get along. All sorts of unrecognized flags and inscrutable errors.
@erunaamo: Thanks for the tip with the ostype. I will try that too. Your experiences tell me, that it has nothing to do with the compiler version. I want to try, if I really need the iPhone SDK installed, because I only have the standard developer tools.
I have downloaded this haxe as I have been waiting for it for a while now, by my mne no longer work ;( the following appear:
Could not link plugin to process (hxCFFILoader.h 48)
And when I try to complile with Cpp I get the following:
haxelib run hxcpp Build.xml haxe -Dcpp -Dhaxe_204 -Dnme -Dtrue
cl.exe -nologo -O2 -MT -DHX_WINDOWS -GR -Zi -c -EHsc -IC:\Program Files\Motion-T
win\haxe\lib\hxcpp\1,0,2//include -D_CRT_SECURE_NO_DEPRECATE -wd4996 -Iinclude .
/src/Hash.cpp -Foobj/Release/src/Hash.o
'cl.exe' is not recognized as an internal or external command,
operable program or batch file.
Called from <null> line 1
Called from BuildTool.hx line 611
Called from BuildTool.hx line 292
Called from BuildTool.hx line 315
Called from BuildTool.hx line 379
Called from BuildTool.hx line 106
Uncaught exception - Error : 1 - build cancelled
Error : Build failed
I Switch back to haxe 2.03 and everything work perfectly :(
cl.exe is the C compiler which is part of Microsoft Visual Studio. You need to setup a C compilation environment before being able to use haXe/C++
I second the previous mentions on adding Python support :)
A lot of valuable applications have Python plugin support which is a great feature and can be a great time saver, but learning yet another language...ugh, well you know...
If haXe were to target it, what a joy it would be :)
Again, thanks for all the hard work.
Supporting Java would be great too, we could make both a SWF file, a Java Applet and a JavaScript file from the same source code. In addition, it would enable us to target Google Android or any mobile phone that has Java Micro Edition installed.