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

< Prev | Page 1 / 1 | Next >