hashlink: HashLink output not working

Hi I’m trying to compile to native using HashLink and I can’t make it work I’m using Ubuntu 17.10, Haxe 4.0.0.preview.3 and HashLink 1.5

I can compile to C but compiling using GCC throws a bunch of errors and fails commands haxe -hl output.c -cp src -lib heaps -lib hlsdl -main Main gcc -o myapp -I. -D INCLUDE_ALL -std=c11 output.c -Lhl

https://pastebin.com/MNcKBRpX

also compiling to .hl works but running that throws another error haxe -hl output.hl -cp src -lib heaps -lib hlsdl -main Main hl output.hl src/module.c(296) : FATAL ERROR : Invalid signature for function sdl@gl_options : Piiiii_v required but Piiiiii_v found in hdll I’m following compilation instructions from here: https://hashlink.haxe.org/

So basically can’t make it work in any way, please help

thanks

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Comments: 19 (6 by maintainers)

Most upvoted comments

In summary I used

  • Haxe 4.0.0-preview.3
  • Heaps from git repo as well
  • Compiled Hashlink from github
  • used hlsld from that same code source haxelib dev hlsdl path/to/hashlink/libs/sdl

to compile, which I did on Kubuntu 17.10, installed the dependencies, GCC, SDL, OpenAL, OpenGL etc. then to compile I used this commands

To generate the C source haxe -hl output.c -cp src -lib heaps -lib hlsdl -main Main

To compile the native app gcc -o myapp output.c -I. sdl.hdll ui.hdll fmt.hdll openal.hdll ui.hdll uv.hdll -lhl -lSDL2 -lm -lopenal -lGL

order of those options are REALLY important, have all those libs after the *.hdll

and that should work, I only did this on Linux so, windows and Mac would be a bit different

let me know if there are any issues

Good luck.

@ncannasse thanks for the reply. It helped a lot.

nm sdl.hdll still wont find the lib. After some trials and reading man nm I found it wont use the PATH or LD_LIBRARY_PATH even if they set correctly. It just need the full path to object file or to be called in the same directory.

I’ve created a simple bash script. Could be an inline command but this reads better and can be reused if put in parent of ./out directory. Also turns out there’s no matter where to put main.c -o main. You just need to set full paths to *.hdll files.

Now the code is compiling and running well.

I’ve ended with these scripts to compile:

$ cat compile-hl-c.hxml

-lib heaps
-lib hlsdl
-hl out/main.c
-main Main

and

$ cat compile

#!/bin/sh

haxe compile-hl-c.hxml &&
cd out &&
gcc main.c -o main \
  -I. \
  /usr/local/lib/sdl.hdll \
  /usr/local/lib/ui.hdll \
  /usr/local/lib/fmt.hdll \
  /usr/local/lib/openal.hdll \
  /usr/local/lib/ui.hdll \
  /usr/local/lib/uv.hdll \
  -lhl -lSDL2 -lm -lopenal -lGL

I asked on behalf on all users. I will try again but probably not at the moment.