[SOLVED] Static linux build?

Hi there!

I’m currently evaluating Haxe for a new hobby project I’d like to start which for a start should be able to run on various embedded linux machines (arm, x86, x64, …) and I’d like to reuse some library code later on for an android app.

I’ve found the HelloWorld.hx sample and compiled it in a subdirectory using
haxe -main HelloWorld -cpp cpp

I then copied the binary to another (embedded instead of desktop) x64 linux machine where it doesn’t print the HelloWorld but instead gives this error:

./HelloWorld: /lib/libstdc++.so.6: version `GLIBCXX_3.4.21' not found (required by ./HelloWorld)

So I’ve looked for a way to get a static compile, and I found
haxe -main HelloWorld -cpp cpp -D static_link
But that only gave me a HelloWorld.a library file and not an executable.

UPDATE: So I found this question today:

which has 1 answer that ends with:

If you want, try experimenting with changing the HXCPP toolchain for Linux to enable a static libstdc++ library if=“static_link” and share the results here or on the Haxe community forum.

So if I understand that correctly it is not possible at the moment to compile a binary that will run on a different system with a different version of glibc++ installed, without some extra work on the way haxe compiles a binary that probably requires some deeper insight than of a newbie evaluating haxe. Correct?

Please help.

When you use Kha, the C libs are always linked statically. But if you don’t want to do that (for whatever weird reason), it’s just two parameters for gcc, shouldn’t be too hard to modify hxcpp accordingly.

Thank you @RobDangerous for the reply!

I have no idea what Kha is so I will have a look at that.

I don’t know too much about C & C++, I’ve learned them in school but never used them for anything practical and especially with C++ I never felt comfortable.

So if you have any pointers for me where and what to learn first I’d be very grateful!

UPDATE: okey, so Kha is a gaming API based on haxe if I understood that correctly?

Is it sensible to use Kha for a non graphical project? I plan to get started with a CLI and later add a boring GUI that runs on Mobile devices with a final step to maybe run in browsers.

No, Kha is of no use to a cli app. The relevant parameters are -static-libgcc and -static-libstdc++, you’ll just have to find the right place in hxcpp’s build system and put them in. No need to learn C/C++ for that. Maybe in hxcpp/gcc-toolchain.xml at master · HaxeFoundation/hxcpp · GitHub or maybe somewhere else (I never used hxcpp’s standard toolchain).

Okey. Thanks for the help @RobDangerous !

Will search for a way to get these parameters into the build.

(If anybody else reads this and knows how to save me from having to search I’d love to read from you!)

UPDATE 2018-09-22:
Got it now. Found the solution (not exactly but in principal) here:

See also my documentation here: