Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HashLink output not working #124

Closed
varomix opened this issue Mar 13, 2018 · 19 comments
Closed

HashLink output not working #124

varomix opened this issue Mar 13, 2018 · 19 comments

Comments

@varomix
Copy link

varomix commented Mar 13, 2018

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

@shakesoda
Copy link
Contributor

shakesoda commented Mar 13, 2018

your sdl.hdll is outdated, and you want -lhl not -Lhl. you'll also want the hdlls in your build (i.e. gcc -o myapp output.c -I. -lhl -lSDL2 sdl.hdll ui.hdll). set LD_LIBRARY_PATH to the location of the up to date hdlls if it still doesn't work (LD_LIBRARY_PATH=. ./myapp)

@varomix
Copy link
Author

varomix commented Mar 13, 2018

Hi
thank you for that
I built HashLink from Git so I think they should be up to date

well something different happened, but is still not building
I got this error now
gcc -o myapp output.c -I. -lhl -lSDL2 sdl.hdll ui.hdll
/usr/bin/ld: /tmp/ccM9HboN.o: undefined reference to symbol 'fmod@@GLIBC_2.2.5' //lib/x86_64-linux-gnu/libm.so.6: error adding symbols: DSO missing from command line collect2: error: ld returned 1 exit status

thanks again

@shakesoda
Copy link
Contributor

shakesoda commented Mar 13, 2018 via email

@varomix
Copy link
Author

varomix commented Mar 13, 2018

more errors but seems to me that we're making progress :)
gcc -o myapp output.c -I. -lhl -lSDL2 -lm sdl.hdll ui.hdll

output to big see it here please
https://pastebin.com/XfBHBh4k

thanks

@shakesoda
Copy link
Contributor

per the function signatures, this time you need fmt.hdll -lopenal -lGL

@varomix
Copy link
Author

varomix commented Mar 13, 2018

not there yet but close
gcc -o myapp output.c -I. -lhl -lGL -lSDL2 -lm -lopenal sdl.hdll ui.hdll fmt.hdll openal.hdll ui.hdll uv.hdll

/tmp/ccIX5K64.o:(.data.rel+0x5dc8): undefined reference to sdl_create_cursor_from'
/tmp/ccIX5K64.o:(.data.rel+0x5dd0): undefined reference to sdl_create_system_cursor' sdl.hdll: undefined reference to glDrawArrays'
sdl.hdll: undefined reference to glColorMask' sdl.hdll: undefined reference to glBlendEquation'
sdl.hdll: undefined reference to glClear' sdl.hdll: undefined reference to glDisable'
sdl.hdll: undefined reference to glViewport' sdl.hdll: undefined reference to glTexImage2D'
sdl.hdll: undefined reference to glReadPixels' sdl.hdll: undefined reference to glPixelStorei'
sdl.hdll: undefined reference to glGetError' sdl.hdll: undefined reference to glActiveTexture'
sdl.hdll: undefined reference to glDepthMask' sdl.hdll: undefined reference to glTexParameterf'
sdl.hdll: undefined reference to glGetString' sdl.hdll: undefined reference to glDepthFunc'
sdl.hdll: undefined reference to glBlendFunc' sdl.hdll: undefined reference to glReadBuffer'
sdl.hdll: undefined reference to glPolygonMode' sdl.hdll: undefined reference to glScissor'
sdl.hdll: undefined reference to glEnable' sdl.hdll: undefined reference to glDrawElements'
sdl.hdll: undefined reference to glTexImage3D' sdl.hdll: undefined reference to glClearDepth'
sdl.hdll: undefined reference to glBindTexture' sdl.hdll: undefined reference to glCullFace'
sdl.hdll: undefined reference to glDeleteTextures' sdl.hdll: undefined reference to glTexParameteri'
sdl.hdll: undefined reference to glGenTextures' sdl.hdll: undefined reference to glFlush'
sdl.hdll: undefined reference to glClearColor' sdl.hdll: undefined reference to glClearStencil'
sdl.hdll: undefined reference to glFinish' collect2: error: ld returned 1 exit status

@shakesoda
Copy link
Contributor

bad link order, put -lGL later

@varomix
Copy link
Author

varomix commented Mar 13, 2018

had it all over the place, is not working

gcc -o myapp output.c -I. -lhl -lSDL2 -lm -lopenal -lGL sdl.hdll ui.hdll fmt.hdll openal.hdll ui.hdll uv.hdll

same output

@varomix
Copy link
Author

varomix commented Mar 13, 2018

Ok fixed the GL issues by putting the libs after the hdlls

gcc -o myapp output.c -I. sdl.hdll ui.hdll fmt.hdll openal.hdll ui.hdll uv.hdll -lhl -lSDL2 -lm -lopenal -lGL
now I get this

/tmp/cc8amjjA.o:(.data.rel+0x5dc8): undefined reference to sdl_create_cursor_from'
/tmp/cc8amjjA.o:(.data.rel+0x5dd0): undefined reference to sdl_create_system_cursor' collect2: error: ld returned 1 exit status

thank you

@varomix
Copy link
Author

varomix commented Mar 13, 2018

It finally works, had to use hsdl that comes with hashlink
haxelib dev hlsdl path/to/hashlink/libs/sdl

that was quite a challenge :)

@Justinfront
Copy link

Varomix If you get a chance it would be good if you can summarise the steps you needed.

@varomix
Copy link
Author

varomix commented Mar 14, 2018

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.

@Justinfront
Copy link

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

@Doppp
Copy link

Doppp commented May 7, 2018

I actually have this issue on Windows. I tried linking my hlsdl to the one in the HashLink source like @varomix but it still breaks for me.

@ncannasse
Copy link
Member

Fixed, please update haxelib hlsdl library for hashlink 1.5 usage

@slouffka
Copy link

slouffka commented Oct 27, 2018

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.

I did all the same but using https://haxe.org/download/file/4.0.0-preview.5/haxe-4.0.0-preview.5-linux64.tar.gz/ and on Arch Linux. Linker still complains:

/usr/bin/ld: /tmp/ccUzUUfH.o:(.data.rel+0x80c0): undefined reference to `sdl_win_destroy'
/usr/bin/ld: /tmp/ccUzUUfH.o:(.data.rel+0x80c8): undefined reference to `sdl_set_vsync'

I've set haxelib dev hlsdl ~/dev/hashlink/libs/sdl pointing to my hashlink installation directory.

Also I use this params to compile:

gcc -o main main.c -I. -lhl -lSDL2 -lm -lopenal -lGL

...because hdll's are not found if I add them to list:

gcc: error: sdl.hdll: No such file or directory
gcc: error: ui.hdll: No such file or directory
gcc: error: fmt.hdll: No such file or directory
gcc: error: openal.hdll: No such file or directory
gcc: error: ui.hdll: No such file or directory
gcc: error: uv.hdll: No such file or directory

Could that be the reason of undefined references? How to add them properly?

@slouffka
Copy link

gcc -o main main.c -I. -L/usr/local/lib sdl.hdll ui.hdll fmt.hdll openal.hdll ui.hdll uv.hdll -lhl -lSDL2 -lm -lopenal -lGL

Still gives the same result.

ls -1 /usr/local/lib 
fmt.hdll
libhl.so
libstlink.a
mysql.hdll
openal.hdll
pkgconfig
sdl.hdll
ssl.hdll
ui.hdll
uv.hdll

export LD_LIBRARY_PATH=/usr/local/lib don't help either.

@ncannasse
Copy link
Member

@slouffka try to put all the hdll (+ -L) before main.c, you can also make sure the symbols are part of the hdll by using nm sdl.hdll | grep std_win_destroy

@slouffka
Copy link

slouffka commented Oct 27, 2018

@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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants