No such file 'haxe' sublime text 3 - sublimetext3

I'm trying to compile haxe in sublime text 3 but I always get the error:
[Errno 2] No such file or directory: 'haxe'
[cmd: ['haxe', 'build.hxml']]
[dir: /home/bob/Desktop]
[path: /usr/local/bin:/usr/bin:/bin:/usr/local/sbin:/usr/sbin:/home/bob/.local/bin:/home/bob/bin]
[Finished]
I'm running fedora 22 and have the Haxe tar extracted in my home folder and I also Ctrl+Shift+P and installed haxelib and Haxe packages. My two files are heloWorld.hx
class HelloWorld {
static public function main() {
trace("Hello World");
}
}
and a build.hxml generated:
# Autogenerated build.hxml
# hellowWorld (js:hellowworld.js)
-main hellowWorld
js hellowworld.js
Why isn't haxe a build system option or it not compiling at all?

I found out I needed to add the haxe exacutables to /usr/bin/ because it is where paths are commonly looked for on linux. Another problem that occurs is that no matter if the class name is lower case or not I get the error:
Error: Could not process argument haxe -main HelloWorld
Class name must start with uppercase character
Build failed

Related

Can't build Haxe source file

I tried haxe on MacOS, and setup the toolchain correctly, etc., but when i tried to compile a file, i got an error, so i tried again with an example in the tutorial (here: https://haxe.org/documentation/introduction/language-introduction.html),
and got the same error, which is:
Type not found : HelloWorld
for the command:
haxe -main HelloWorld -js HelloWorld.js
to compile the file:
class HelloWorld {
static public function main() {
trace("Hello World");
}
}
What am i doing wrong?
Make sure that your haxe source file is named as HelloWorld.hx and your working directory is at where the source file is, when you run the compile command

Haxe: How to use a .NET C++/CLI dll in haxe code?

I've been trying to use Haxe to generate C# code that calls methods from a dll written in C++/CLR. This dll is called "AudioClientSDK.dll"
Here is an example of the Haxe code I'm trying:
package hello;
class HelloWorld {
static public function main():Void {
var s = untyped __cs__("AudioClientCLR.AudioClientAPI.release()");
}
}
As you can see I'm using "Haxe magic" syntax (I previously tried Haxe extern classes that resulted pretty much in the same problems) to directly call the release method within the AudioClientSDK.dll. The method signature inside the dll is:
public : void AudioClientCLR::AudioClientAPI::release()
However, when I try to compile this code, Haxe throws this error:
haxe -cp src -cs out/CS -main hello.HelloWorld
haxelib run hxcs hxcs_build.txt --haxe-version 3103
c:\git\HelloHaxe\src\hello\HelloWorld.hx(6,16): error CS0103: The name
'AudioClientCLR' does not exist in the current context
Compilation error
Native compilation failed
Error: Build failed
If I try to pass the AudioClientSDK.dll reference as -net-lib or -net-std I get these errors:
haxe -cp src -cs out/CS -net-lib lib/CPP/x86/AudioClientSDK.dll -main hello.HelloWorld
File "ilMetaReader.ml", line 281, characters 36-42: Assertion failed
error 0x2
haxe -cp src -cs out/CS -net-std lib/CPP/x86/AudioClientSDK.dll -main hello.HelloWorld
Error: No .NET std lib directory with the pattern 'net-20' was found in the -net-std search path. Try updating the hxcs lib to the latest version, or specifying another -net-std path.
Do any of you know how to correctly use the dll?
Thanks in advance.
P.S. These are some properties of the AudioClientSDK.dll:
Targeted framework: .NETFramework,Version=v4.0
Platform: Win32
Platform Toolset: VisualStudio 2010 (v100)
Use of MFC: Use MFC in a Shared DLL
Common Language Runtime: Common Language Runtime Support (/clr)
Also, please note that this dll can be used without problems from C# in Visual Studio.
This seems like a bug. Please report it ASAP to the haxe issue list, with a downloadable link to the offending dll, and it might get included inyo the 3.2 final release

Haxe can't find std libraries

I am trying to setup Haxe with IntelliJ and my Linux box. I downloaded Linux 64bit binaries from haxe(haxe 3.1.3) site and community edition intellij. I installed Haxe plugin in intellij and then created a new Haxe Module. For sdk I picked the haxe folder I donwloaded from haxe site. I created a new configuration to compile and run but It gives me an error that It can't locate standard library. Why is that happenning?
Haxe Directory Tree
haxe-3.1.3
├── extra
└── std
├── cpp
├── cs
├── flash
├── flash8
├── haxe
├── java
├── js
├── neko
├── php
├── sys
└── tools
haxe-3.1.3 was the directory I chose for haxe toolbox in intellij. Creating a new Haxe project lets me choose Haxe 3.1.3 (meaning that toolkit is set up correctly since its recognized). External Libraries in intellij project includes Haxe dir with std (when expanding the folder to see what it contains).
In "Project structure" dialog in the SDK i see that libraries are setup correctly (haxe-3.1.3/std) and the haxe executable also(haxe-3.1.3/haxelib). Classpath contains the Library directory
When I compile it using openFl and with flash as target I get the following error
Error:compilation failed
/home/avlahop/development/Haxe/haxe-3.1.3/haxelib
Error:libneko.so: cannot open shared object file: No such file or directory
When I switch to Haxe compiler and Neko or Javascript I get the following
Information:Compilation completed with 1 error and 1 warning in 0 sec
Information:1 error
Information:1 warning
Error:compilation failed
Warning:Standard library not found
My Class
package ;
class Test3 {
public function new() {
}
public static function main(): Void{
trace("Hello from haxe and IntelliJ IDEA");
}
}
I really want to get in to it but cannot start...
Manually go into /usr/lib and look for libneko.so. Sometimes installs might throw a one at the end or something aka libneko.so.1.
Rename the file correctly. You may have to use a newer version of neko, I had to compile from the git to get it to work: https://github.com/HaxeFoundation/neko
If you don't notice anything off, make sure your environment variables are correct. Open up /etc/environment in the text editor of your choosing
export HAXE_STD_PATH=/usr/local/haxe/std:. # path to std + :.
export HAXE_HOME=/usr/whatever/haxe # path to haxe
export NEKOPATH=/usr/local/neko # path to neko
Note that if you used HAXE_LIBRARY_PATH, that's been changed to HAXE_STD_PATH in later versions of Haxe. You also need the reference to this file, open your /etc/profile with sudo and check for:
. /etc/environment
That's all I got. Hope it works out for you.
Based on #johnink anwser, this work for me in linux commandline mode :
I downloaded linux binaries from https://haxe.org/download/ and uncompress in some path like
/some/folder/haxe-tool
I added this lines to my ~/bashrc
export HAXE_STD_PATH="/some/folder/haxe-tool/std"
export HAXE_HOME="/some/folder/haxe-tool"
export PATH=$PATH":"$HAXE_HOME
And tested with this cmd:
haxe -main HelloWorld --interp
Also I converted to javascript with this cmd
haxe -js HelloWorld.js -main HelloWorld
Using this file :
class Main {
static public function main():Void {
trace("Hello World");
}
}
Following the "Hello World" example :
https://code.haxe.org/category/beginner/hello-world.html

Cygwin : error: package net.jradius.packet.attribute does not exist

This doesn't appear to be the usual CLASSPATH issue, but maybe something specific to cygwin.
The following illustrates the issue.
import net.jradius.packet.attribute.AttributeFactory;
public class Test{
static int x = 100;
}
When compiling the following error appears.
$ javac Test.java
Test.java:1: error: package net.jradius.packet.attribute does not exist
import net.jradius.packet.attribute.AttributeFactory;
^
1 error
The file jradius-core-1.1.4.jar is in the CLASSPATH.
When using the command line within Windows it works. Here is the classpath.
set CLASSPATH=c:\Temp\jradius-core-1.1.4.jar
When using cygwin it produces the error. Here is the classpath.
export CLASSPATH=/cygdrive/c/Temp/jradius-core-1.1.4.jar
The location is valid via cygwin as the following shows it is recognized.
ls $CLASSPATH
/cygdrive/c/Temp/jradius-core-1.1.4.jar
The same JDK is used for both scenarios.
Any idea why it may be failing via cygwin???
You are using JDK built for windows, so the environment is for windows.
That's being said, you should be provide windows-style path to javac.
cygpath is what you are looking for here.
Try:
javac Test.java -cp `cygpath.exe -w /cygdrive/c/Temp/jradius-core-1.1.4.jar`
cygpath -w means print in windows style.
Or just put the jar file in the same directory of the java file, and in cygwin:
javac Test.java -cp jradius-core-1.1.4.jar
Refer from this
Added the JAR files into the directory and changed the classpath to include '*' and that appears to have worked.

Class not found : helloworld.Main

I just began to learn Haxe, but I have encountered Compile error.
Main.hx
package helloworld;
import js.Lib;
class Main {
static function main() {
Lib.alert("Hello World");
}
}
Please be careful about the target class is helloworld.Main.
build.hxml
-js bin/HelloWorld.js
-cp src
-main helloworld.Main
-debug
Build process log
Building HelloWorld_p140627
Running Pre-Build Command Line...
cmd: C:\HaxeToolkit\haxe\haxe.exe X:\tmp\HelloWorld_p140627\build.hxml
Class not found : helloworld.Main
Build halted with errors.
Done(1)
Why? The class helloworld.Main is surely exist. I cannot even say "hello, world"?
Update now that I can see a screenshot of your project:
You are trying to compile "helloworld.Main", that means a class called "Main" in the package "helloworld", so Haxe will be looking for a file called "helloworld/Main.hx" in your "src/" directory.
However you have "src/Main.hx", not "src/helloworld/Main.hx". Create a subfolder called "helloworld", move "Main.hx" in there and you will be fine. The package you use in Haxe must match the directory structure.
Make sure your package aligns with your folders, and your file name with your class name. And all of these should be inside one of your "-cp" class path folders.
For your example above, the code looks fine, I would expect your layout to look like:
build.hxml <-- build file
src/helloworld/Main.hx <-- classpath/package/class.Hx
bin/ <-- output folder
bin/HelloWorld.js <-- will be created once it compiles
And then you'd run haxe build.hxml. If that doesn't work for you please post the exact file structure of your project (which folders and which directories), and the command you use to build it, and the output.
Hope that helps,

Resources