Haxe Forum > Start

  • Hello World!

    I was wondering how to start a program with haxe, I have experience with Java, but I mainly used eclipse. So, I get the basic syntax of haxe, so in order to see if it was working, I tried using one of the sample codes (to be specific, the "Hello World" code). The problem is that it didn't work, so here's what I did:
    1. I created a file called Hello.
    2. I put int the code that was in the sample:

    class Hello {
        static function main() {
            trace("Hello World!");
        }
    }

    3. I ran it in the command line:
    $ haxe Hello
    But it game me and error, which is as following:
    Class not found : Hello

    I'm guessing that the problem is not with the code, but with the file name or something, maybe I forgot to make it an executable, but either way, it's not working. Can anyone tell me what I did wrong?

    Thanks!

  • I have tried looking at a few tutorials, but I am still having problems once it comes to the compiling. I am using a file called "test.hx" and my code looks like this:

    class Test {
        public static function main() {
            trace("Hello World!");
        }
    }

    Then, to compile it in neko (so says the tutorial that I must do) I use the following command in the terminal:
    $ haxe -main Test -neko test.n

    This is exactly what the manual says for me to do, is there something I need to know? And I find it quite strange you don't need to specify an input file.

  • You are specifying the file here:
    -main Test
    The flie should be Test.hx and should be the same name as the class inside.

  • ps always test haxe with minimal dependancies ( ie: flash and js and php ) targets don't require neko or cpp, I think flash target is probably the best way to check you have basic haxe setup, then try testing neko target... but I think maybe you have something setup wrong... try working through the basic flash hello world you probably just can't find the file because you not cd to the folder your class is in. You can use -cp to specify where to find your classes.

  • OK, thanks for the help, it all works except for when I use the cpp, it gives me some error saying that I need to use the haxelib setup command, which I already did, unless there's something else I need to do. But anyway, thanks Justin!

  • After haxelib setup you need to install the hxcpp library.
    From command line:

    haxelib install hxcpp

    Jan

  • Yeah, I have it installed, but whenever I try to compile it, it still gives me this same error:

    This is the first time you are runing haxelib. Please run haxelib setup first
    Error : Build failed

    Even though I already ran the haxelib setup and gave it a directory where it can store the libraries.

  • I had a similar problem. Perhaps you could try running the command with sudo if you're using Linux:

    sudo haxelibe install hxcpp
    If that doesn't work may I suggest Haxe NME at www.haxenme.org

  • Great! It works now, but I found out that I need to use root in order to compile it, but it works.
    Thanks!

  • I need to use root in order to compile it

    The reason is probably that you set haxelib by/for root.

    Jan

  • Yeah, but I have no problem with it since I have root access on my laptop, so I'm not bothered by it.

< Prev | Page 1 / 1 | Next >