编辑:因为其他人肯定会遇到同样的问题,所以留下这个,但根本原因是 ubuntu 包是 haxe 的一个非常旧的版本。我卸载了它并从源代码安装,一切正常
我已经在我的 ubuntu 系统上全局安装了 haxe,并将 haxelib 设置为用户,安装路径为 /home/mdemello/opt/share/haxe/lib
haxelib 似乎可以工作,除了安装后错误:
$ haxelib install csv
Downloading csv-0,4,0.zip...
Download complete : 10518 bytes in 4.3s (2.3KB/s)
Install CHANGES.txt
Install haxelib.json
Created lib/
Install LICENSE.txt
Install README.md
Created test/
Install test.hxml
Created lib/format/
Created lib/format/csv/
Install lib/format/csv/Reader.hx
Install lib/format/csv/Utf8Reader.hx
Install lib/format/csv/Data.hx
Install test/Test.hx
Current version is now 0.4.0
Done
Invalid field access : index
但是通过 -lib 使用已安装的库失败;我必须使用 -cp 指定完整路径:
$ head CSV.hx
import format.csv.Reader;
$ haxe -lib csv -x CSV.hx
./CSV.hx:1: characters 7-24 : Class not found : format.csv.Reader
$ haxelib path csv
/home/mdemello/opt/share/haxe/lib/csv/0,4,0/
-D csv
$ haxe -cp /home/mdemello/opt/share/haxe/lib/csv/0,4,0/lib/ -x CSV.hx
# works
编辑:这是运行时的输出haxe -v
:
$ haxe -v -lib csv -x CSV.hx
Classpath : /home/mdemello/opt/share/haxe/lib/csv/0,4,0/;./;/usr/share/haxe/std/neko/_std/;/usr/share/haxe/std/
Defines : true;sys;neko;haxe_ver;haxe_release;haxe3;dce;csv
Parsed /usr/share/haxe/std/StdTypes.hx
Parsed /usr/share/haxe/std/neko/_std/String.hx
Parsed /usr/share/haxe/std/neko/_std/Array.hx
Parsed /usr/share/haxe/std/haxe/EnumTools.hx
Parsed /usr/share/haxe/std/neko/_std/Std.hx
Parsed ./CSV.hx
./CSV.hx:1: characters 7-24 : Class not found : format.csv.Reader
我注意到它从 -lib 添加的类路径是,/home/mdemello/opt/share/haxe/lib/csv/0,4,0/
而我必须通过 -cp 手动添加的类路径是/home/mdemello/opt/share/haxe/lib/csv/0,4,0/lib