I am making this in haxe, just wanted to try something and compile the Haxe code by using HXCPP. I got linker errors on github.
This is the code.
package;
class Main
{
public static function main()
{
trace("havaliyim");
}
}
And here is the error:
Error
Is this happens because i used windows-2022 on workflow?
Related
I was making an project and i need to use Arduino UNO as HID. So, i installed Keyboard library (version 1.0.4) from library manager and write just basic program in new sketch to test it:
#include <Keyboard.h>
void setup() {
// initialize the Keyboard library
Keyboard.begin();
}
void loop() {
Keyboard.press('A');
delay(1000);
Keyboard.release('A');
delay(1000);
}
I compiled it, but it gives me errors:
C:\Users\medic\AppData\Local\Temp\.arduinoIDE-unsaved202314-8852-isv7gn.mjro\sketch_feb4a\sketch_feb4a.ino: In function 'void setup()':
C:\Users\medic\AppData\Local\Temp\.arduinoIDE-unsaved202314-8852-isv7gn.mjro\sketch_feb4a\sketch_feb4a.ino:4:3: error: 'Keyboard' was not declared in this scope
Keyboard.begin();
^~~~~~~~
C:\Users\medic\AppData\Local\Temp\.arduinoIDE-unsaved202314-8852-isv7gn.mjro\sketch_feb4a\sketch_feb4a.ino: In function 'void loop()':
C:\Users\medic\AppData\Local\Temp\.arduinoIDE-unsaved202314-8852-isv7gn.mjro\sketch_feb4a\sketch_feb4a.ino:8:3: error: 'Keyboard' was not declared in this scope
Keyboard.press('A');
^~~~~~~~
exit status 1
Compilation error: 'Keyboard' not found. Does your sketch include the line '#include <Keyboard.h>'?
I was searching on the internet and find a solution to install other libraries. I installed other libraries from GitHub and some sites to try them, but it didn't work.
I have installed wkhtmltopdf using the Windows installer and am using the wkhtmltopdf crate. wkhtmltopdf is installed at C:\Program Files\wkhtmltopdf, which contains (among other things) bin/wkhtmltox.dll and lib/wkhtmltox.lib.
I have successfully gotten Rust to link the .lib at build time with the following build.rs:
fn main() {
#[cfg(windows)]
{
println!("cargo:rustc-link-search=C:/Program Files/wkhtmltopdf/lib");
println!("cargo:rustc-link-lib=dylib=wkhtmltox");
}
}
That (I think) works fine for building; at least, it appears to build successfully (and without this build.rs, it fails to build). For running, I've tried using the windows crate to load the DLL at runtime as follows:
#[tokio::main]
async fn main() -> LSResult<()> {
println!("starting main");
#[cfg(windows)]
{
println!("cfg(windows)");
use windows::{
core::PCSTR,
Win32::{
Foundation::HANDLE,
System::LibraryLoader::{
AddDllDirectory, LoadLibraryExA, SetDefaultDllDirectories,
LOAD_LIBRARY_SEARCH_DEFAULT_DIRS, LOAD_LIBRARY_SEARCH_DLL_LOAD_DIR,
},
},
};
// Add the wkhtmltopdf DLL path to the DLL search path
let dll_path = r#"C:\Program Files\wkhtmltopdf\bin\wkhtmltox.dll"#;
let dll_path_pcstr_bytes = dll_path
.bytes()
.chain(std::iter::once(0))
.collect::<Vec<_>>();
unsafe {
LoadLibraryExA(
PCSTR(dll_path_pcstr_bytes.as_ptr() as *const u8),
HANDLE(0),
LOAD_LIBRARY_SEARCH_DEFAULT_DIRS | LOAD_LIBRARY_SEARCH_DLL_LOAD_DIR,
);
}
}
println!("about to get pdf");
wkhtmltopdf::PdfApplication::new().expect("Failed to init PDF application");
println!("got pdf");
}
But, try as I might, I cannot get the DLL to be loaded at runtime. I always get the following error at runtime:
error: process didn't exit successfully: target\\debug\\my_crate.exe (exit code: 0xc0000135, STATUS_DLL_NOT_FOUND)
C:/Users/me/.cargo/bin/cargo.exe: error while loading shared libraries: ?: cannot open shared object file: No such file or directory
None of the println! statements are executed; as soon as cargo run starts running the executable, the STATUS_DLL_NOT_FOUND is thrown. To me this indicates that Rust is trying to load the DLL before main is even called, and failing because it's not on the default DLL search path.
If I comment out the line wkhtmltopdf::PdfApplication::new().expect("Failed to init PDF application"); then it runs fine, everything is printed, etc. So it seems I have to find a way to point the executable to the DLL before even running it!
Also, after installing wkhtmltopdf on my Mac, things "just worked" without needing to do any explicit loading of the dylib. I assume this is because the Mac installation places the shared libraries in a standard location, whereas the Windows installation does not. But on Windows I cannot customize the installation of wkhtmltopdf; rather I must somehow point the executable to the DLL, and seemingly must do so before main is called.
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
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
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,