1

I am a newbie to Haxe. I created the below code:

import restclient.RestClient;
/**
 * ...
 * @author Sriram
 */
class HaxeTest 
{
    static public function main() {
        trace("Hello, world!");
        var result = RestClient.get(
            "SOME_REST_GET_API");
        trace(result);
    }
    
}

I wanted to run the below command:

haxe --js main-javascript.js --main HaxeTest

But I get the below error:

HaxeTest.hx:1: characters 8-29 : Type not found : restclient.RestClient
HaxeTest.hx:10: characters 22-32 : Type not found : RestClient

I have installed the rest-client using haxelib install rest-client

Kindly assist.

Sriram
  • 155
  • 12
  • 1
    You forgot to include the library during the compilation (`--library rest-client`). – Gama11 Oct 19 '20 at 09:14
  • Thanks Gama. My bad I forgot the --library option. I have a doubt, if I have more than one library, do I need to provide them as comma-separated (ex: rest-client, http-client etc). Is there any wild card characters like * or any xmls to add libraries while executing? – Sriram Oct 19 '20 at 09:25
  • 1
    No, you need a separate `--library` per library. Maybe you are looking for HXML files. https://haxe.org/manual/compiler-usage-hxml.html – Gama11 Oct 19 '20 at 10:27
  • Got it. Thanks Gama11 – Sriram Oct 19 '20 at 11:50

1 Answers1

1

Installing a library doesn't directly mean it's used in compilation of the project. You should add -lib rest-client to actually tell the compiler that you want to use this library

haxe --js main-javascript.js --main HaxeTest -lib rest-client
Mark Knol
  • 9,663
  • 3
  • 29
  • 44