Hashlink target build problems

Using the HerokuShaders demo project I built the project using
openfl build hl

Firstly I got the error
chmod: cannot access 'Export/hl/bin/HerokuShaders': No such file or directory

which I got rid of by creating the directory. It then isn’t used in the build process.

Next I changed to directory
Export/hl/bin
And called
hl HerokuShaders.hl

I then get the error
src/module.c(268) : FATAL ERROR : Failed to load library lime.hdll
even though lime.hdll is in the current directory

Anyone know how to sort this out?

I’m running the current git versions of:
haxe (i.e 4.0.0)
lime
hxcpp
hashlink
openfl

on Ubuntu 18.10 (Bionic Beaver)

Ta Muchly,

Harry French

We have about 90% support for HashLink, but it’s not officially supported in our releases, yet.

In order to test our current support, you will need to use Lime from GIT, then rebuild using the -Dhashlink define, such as lime rebuild windows -Dhashlink

Then we expect that you will have a variable defined in your environment called HLPATH for the path to where HashLink is located on your system.

Then lime test hl on a project should probably work.

There are at least three problems for finishing HashLink support:

  1. We use a single native library (lime.so, lime.ndll, etc) for Neko and C++. We wanted to have this working with HashLink as well (-Dhashlink causes Neko and C++ to require libhl.dll or libhl.so, which is not something we want to do)
  2. We would probably need to bundle HashLink ourselves, as HashLink versions are tied to the binaries we generate, and the global install approach is not official, nor worked on Linux when tested
  3. There may be some minor things we did not get right, such as passing Strings to and from C++
3 Likes

Thank you. I’ll report back how it goes.

@singmajesty, thank you for the tip! I tried to build Lime with the “-Dhashlink” flag, but the only artifact that results is “…/ndll/Linux64/lime.ndll”, no “.hdll” file is created. I searched for it, but to no avail. Is there something I am doing wrong here?

I am compiling with the following commands:
lime rebuild linux -64 -release -clean -Dhashlink
cp /path/to/lime/ndll/Linux64/lime.ndll /path/to/lime/ndll/Linux (this fixes the “no lime.ndll found error”)

Then, I am trying to build the BunnyMark lime-sample project:
cd lime-samples/demos/BunnyMark
mkdir -p Export/hl/bin/BunnyMark
lime build hl

When trying to run:
cd Export/hl/bin/BunnyMark
hl ApplicationMain.hl

src/module.c(318) : FATAL ERROR : Failed to load library lime.hdll

lime build hl should copy the NDLL and rename it to HDLL

I had trouble getting HashLink to resolve library paths properly on Linux, so I think we are going to have to look at bundling HashLink in with Lime and copying it into the bin directory upon a build

I found out that building Lime projects does generate a “lime.hdll” file inside the “Export/hl/bin” folder.
You pointed out that there are problems with library findings, so I proceeded as follows:
sudo cp /path/to/lime/ndll/Linux64/lime.ndll /usr/local/lib/lime.hdll
export LD_LIBRARY_PATH=/usr/local/lib
hl ./NameOfExecutable.hl

It runs! But… crashes sometimes.
I have tested it with the lime-samples given here: https://github.com/openfl/lime-samples
Only 2 of them work: the “Hello World” project, and the “BunnyMark” project.

For Game of Life: src/module.c(461) : FATAL ERROR : Invalid signature for function [email protected]_audio_load_file : POBi_OiiOiOiB_iiii_iDDDDDOD___OiiOiOiB_iiii_iDDDDDOD__ required but POBi_OiiOiOiB_iiii_iDDDDDOiD___OiiOiOiB_iiii_iDDDDDOiD__ found in hdll
For HerokuShaders: *** Error in 'hl': free(): invalid pointer: 0x00000000400020a8 ***

Maybe this might help in improving Hashlink support for Lime.

The issue has been fixed, I could compile and run all the Lime examples, targeting Hashlink.

1 Like

I tried this out. The BunnyMark project compiled nicely using lime build hl and resulted in ‘BunnyMark.app’ being created. However the app will not launch on my M1 Mac or Intel Mac. It fails silently. I tried compiling with sudo in case the permissions weren’t getting set properly but to no avail. What should I do?

I recommend using the latest development version of Lime 8 (which we’ll be releasing soon) if you want to target HashLink. We recently merged a pull request that includes the latest HashLink 1.12 and cleans up some of the messy parts of using HashLink with previous versions of Lime. I can confirm it works really well on my M1 Mac.

The easiest way to test a nightly build is to grab a lime-haxelib.zip file from one of the newest successful builds here:

Run the following command to install the downloaded file:

haxelib install lime-haxelib.zip

This is encouraging! Unfortunately I’m not seeing any successful builds on that page. What did I miss doing?

Oops! Discourse mangled the URL. Fixed.

1 Like

Well I have lime set to 8.0.0 now. I generated a new .app. At first I had to approve the lime library after I got the message ‘“lime.ndll” cannot be opened because the developer cannot be verified.’
Now it does the same thing, just won’t launch and fails silently.

Okay, I see. I didn’t need to approve anything on my machine, and lime test hl works for me. However, running the .app file does not.

If I run this from a terminal, it works:

cd MyApp.app/Contents/MacOS
./MyApp

So there must be something about the .app file that needs a little tweaking to work properly.

So it turns out that the HashLink executable expects hlboot.dat and all of the libraries to be in the current working directory. It’s not enough that they’re in the same directory as the HashLink executable, which (I think) is what we were incorrectly assuming.

When you double-click the .app file, the current working directory is not automatically the directory that contains the HashLink executable, so it is looking for hlboot.dat and stuff in the wrong place.

It looks like we need to somehow change the current working directory before launching the HashLink executable.

Thanks so much for confirming I’m not just inept! :slight_smile:
I am also able to run the executable from terminal like you describe.
Since this is making a Mac application, what does one do to create a Windows exe? Run the same build in a Windows environment?

Yes, and similarly, to create a Linux executable, you need to run the build on Linux.

1 Like

Please give the latest Lime nightly a try. I think I got double-clicking the .app file to work properly on macOS.

2 Likes

It works! I just had to grant permissions again in the Security panel after getting the message again about lime.ndll.

Thanks!

I’m curious if the same issue occurs when you use lime test hl instead of double-clicking the .app file.

If it happens only when double-clicking the .app file, that makes sense, and shouldn’t be too annoying. For distribution to users, you’ll need to sign/notarize the .app file with Apple anyway. Once properly notarized, no one should get the “developer cannot be verified” message.

Lime test hl works fine but there’s no permission error.
I am not sure how to reset the permission. It seems that the ndll instantly becomes an hdll; I’m guessing it has the same hash so the OS thinks it’s okay.
I am definitely not at the signing stage yet or anytime so I should be good for now. Thanks again!