I want to use Haxe to write a library that can be used by other projects in various different languages.
Currently I have at the top of my library:
import neko.io.File;
import neko.io.FileInput;
import neko.io.FileOutput;
import neko.FileSystem;
import neko.io.Process;
So my library compiles to neko just fine, using the -neko
flag. However if I try to use the -cpp
flag, the packages cannot be found:
$ haxe -cp src -main sws/Root.hx -cpp build/sws.CXX
src/sws/Root.hx:3: characters 0-20 : You can't access the neko package with current compilation flags (for neko.io.File)
I thought the solution would be to instead do the imports like this:
import sys.io.File;
import sys.io.FileInput;
import sys.io.FileOutput;
import sys.FileSystem;
import sys.io.Process;
and let Haxe change sys
into neko
or cpp
depending on the compile flag I use. (Assuming all the modules are available in all the target languages.) But that doesn't work either.
$ haxe -cp src -main sws/Root.hx -neko build/sws.n
src/sws/Root.hx:3: characters 0-19 : Class not found : sys.io.File
$ haxe -cp src -main sws/Root.hx -cpp build/sws.CXX
src/sws/Root.hx:3: characters 0-19 : Class not found : sys.io.File
How should I be doing it?