haXe Forum > Problem getting started with hxcpp

  • I'm trying to get a simple "Hello World" program compiled using Haxe cpp, but can't seem to get it working. The program is

    class Hello {
        static function main() {
            cpp.Lib.print("Hello World!");
        }
    }

    but compiling gives

    peter@HAL:~/haxe$ haxe -main Hello.hx -cpp Hello
    haxelib run hxcpp Build.xml haxe -Dcpp -Dhaxe_205 -Dtrue
    mkdir obj                                               
    mkdir obj/linux                                         
    mkdir obj/linux/src                                     
    mkdir obj/linux/src/cpp
    ... snipped ... (seems OK)
    /usr/lib/haxe/lib/hxcpp/2,05,1//src/hx/GCInternal.cpp: In member function ‘void BlockData::Verify()’:                                                           
    /usr/lib/haxe/lib/hxcpp/2,05,1//src/hx/GCInternal.cpp:295: error: ‘printf’ was not declared in this scope                                                       
    /usr/lib/haxe/lib/hxcpp/2,05,1//src/hx/GCInternal.cpp: In member function ‘AllocType BlockData::GetAllocType(int, bool)’:                                       
    /usr/lib/haxe/lib/hxcpp/2,05,1//src/hx/GCInternal.cpp:359: error: ‘printf’ was not declared in this scope                                                       
    /usr/lib/haxe/lib/hxcpp/2,05,1//src/hx/GCInternal.cpp:373: error: ‘printf’ was not declared in this scope                                                       
    /usr/lib/haxe/lib/hxcpp/2,05,1//src/hx/GCInternal.cpp:391: error: ‘printf’ was not declared in this scope                                                       
    Called from <null> line 1                                                       
    Called from BuildTool.hx line 840                                               
    Called from BuildTool.hx line 433                                               
    Called from BuildTool.hx line 456                                               
    Called from BuildTool.hx line 529                                               
    Called from BuildTool.hx line 561                                               
    Called from BuildTool.hx line 166                                               
    Uncaught exception - Error : 256 - build cancelled          

    This is with Haxe 2.05 on Ubuntu Karmic, and GCC 4.4.1. Compiling equivalent programs to SWF/Neko/etc works fine, and there are no issues with GCC that I can see.

    What am I doing wrong?

    Cheers,
    Peter

  • Adding

    #include <cstdio>
    to: /usr/lib/haxe/lib/hxcpp/2,05,1//src/hx/GCInternal.cpp
    works for me.

    Mockey

  • Ah! Thanks for that. (Though, for reference, I had to do the same thing for StdLibs.cpp as well to get it working.)

    Cheers,

    Peter

  • Seconded. I gave up first time since this feels so n00bish.. but thanks!
    Looking at NME examples now :)

  • That still doesn't seem to fix it for me. I'm on Windows and am getting this:

    haxe -cp "C:\Users\Admin\Documents\testprj\src" -cp "C:\Program Files (x86)\FlashDevelop\Library\HAXE\classes" -main Main -cpp "bin" -debug
    haxelib run hxcpp Build.xml haxe -Ddebug -Dcpp -Ddebug -Dhaxe_205 -Dtrue
    cl.exe -I. -nologo -Od -MTd -DHX_WINDOWS -GR -Zi -c -EHsc -IC:\Program Files (x86)\Motion-Twin\haxe\lib\hxcpp\2,05,1//include -D_CRT_SECURE_NO_DEPRECATE -wd4996 -Iinclude -Yuhxcpp.h ./src/cpp/Lib.cpp -Foobj/Debug/src/cpp/Lib.obj
    Called from <null> line 1
    Called from BuildTool.hx line 840
    Called from BuildTool.hx line 433
    Called from BuildTool.hx line 456
    Called from BuildTool.hx line 529
    Called from BuildTool.hx line 561
    Called from BuildTool.hx line 166
    Uncaught exception - Error : -1073741515 - build cancelled
    Error : Build failed
    Build halted with errors (haxe.exe).

< Prev | Page 1 / 1 | Next >