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?
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.
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).