HaxeFoundation / haxe.org-comments

Repository to collect comments of our haxe.org websites
2 stars 2 forks source link

[haxe.org/manual] HashLink/C Compilation #67

Open utterances-bot opened 4 years ago

utterances-bot commented 4 years ago

HashLink/C Compilation - Haxe - The Cross-platform Toolkit

Haxe is an open source toolkit based on a modern, high level, strictly typed programming language.

https://haxe.org/manual/target-hl-c-compilation.html

mangoducksparkles commented 3 years ago

On linux, I had to use:

gcc -o main out/main.c -Iout /usr/local/lib/*.hdll -lhl -lSDL2 -lm -lopenal -lGL

-Iout adds the out directory to the linker so it can find all the other files in there.

/usr/local/lib/*.hdll is where all the hdll files are kept because I built and installed hashlink from source.

The remaining arguments load various libraries necessary to make the native executable.

I found this info here: https://github.com/HaxeFoundation/hashlink/issues/124

rezdh commented 2 years ago

The VS part -D hlgen.makefile=vs2019 didn't work for me.

tobil4sk commented 2 years ago

@amrezzd For now vs2019 was removed temporarily (due to performance issues), vs2015 or vs2017 are still available.

daxtron2 commented 2 years ago

Trying to run haxe --main Main --hl out/main.c -D hlgen.makefile=vs2017 but no solution file is generated. I only have the 2017 build tools do I need the full install for 2017?

tobil4sk commented 2 years ago

Make sure you have an up-to-date version of the hashlink helper library. As mentioned here, You can install an up-to-date version using:

haxelib git hashlink https://github.com/HaxeFoundation/hashlink.git master other/haxelib/

I think the build tools should be enough.

ThePlank commented 1 year ago

I can't get the VS part of compilation, i have both VS2019 and VS2017 and when building with -D hlgen.makefile=vs2017 it returns Code generated in out/main.c automatic native compilation not yet implemented and missing hlc_main.c?

tobil4sk commented 1 year ago

The message Code generated in out/main.c automatic native compilation not yet implemented is normal, it is referring to the fact that, as of now, the code generated does not automatically get compiled for you, even if you create a Visual Studio project to make it easier to do manually.

In the output directory (out/) there should be a main.vxproj file which you should open and build. I assume this stage is where you are experiencing the hlc_main.c error. It seems like there is a problem with the HASHLINK environment variable. Did you make sure to set it?

First, the HASHLINK environment variable must be set up, pointing to the Hashlink install location. This is necessary as it is used within the project files to locate the Hashlink sources.

Make sure that it has been set, and then restart Visual Studio (and any terminals you are building from).

fy0 commented 6 months ago

Still unavaliable to generate vs project. Just provide precompiled libraries for gcc on windows please, everything will be simple!

fy0 commented 6 months ago

Here is a method to direct compile with msvc's cl.exe:

haxe --main Main --hl=out/main.c
cd out

set hashlink=C:\HaxeToolkit\hashlink
cl.exe /Ox /Fe -I "%hashlink%\include" -I "." "main.c" "%hashlink%\ssl.lib" "%hashlink%\directx.lib" "%hashlink%\openal.lib" "%hashlink%\fmt.lib" "%hashlink%\libhl.lib"