Exporting to .exe format?

Hi,

First post here.
I’ve made a quick search but couldn’t find guidelines for exporting to a Windows executable. Does anyone have an idea of how this can be achieved (btw I’m very new to heaps)

Thanks

You can use HashLink.

Hi!

To give some further information for others searching answers:

Sample for GCC

Step 1

My .hxml-file for using Hashlink to compile to C

-lib heaps
-lib hlsdl
# -lib hldx # you could also use this instead of hlsdl, as you're targeting windows

-cp src
# -p res # this would be for adding a path to your resource/assets directory

-main Main

-D windowSize=1024x768

# -hl app.hl # this would be for debugging
-hl out/c/main.c # this is for generating c code via hashlink

(note it can happen that you need to delete all #-marked lines; just for in case)


Step 2

My .bat-file (put inside of the newly generated directory with main.c and hlc.json)

haxelib run hlc-compiler --srcDir ./ --outDir ../exe/ --hlLibDir "C:\Programs\HaxeToolkit\haxe\lib\hashlink\hl-1.11.0-win" --hlIncludeDir "C:\Programs\HaxeToolkit\haxe\lib\hashlink\hashlink-master\src" --copyRuntimeFiles --exFile C:\Windows\System32\dbghelp.dll -O3
pause

As you can see here I use Haxe’s hlc-compiler. Of course you need to replace the paths to point to the right directories on your system.

There is a YouTube-tutorial on how to do that. It also explains some things when using Microsoft Visual Studio compiler.

And there is another thread from the forum particularly on step 2: compiling hl/c.

I hope this can help.


PS:
(Maybe one day there’ll be a super duper doc explaining every step and case straightforward/verbosely for everyone; including Haxe’s hlc-compiler, Yanrishatum’s HLCC and using GCC etc. directly :wink: )

2 Likes

My little guide above has a little mistake, because when I use HLCC it uses MSVC/cl.exe to compile, not GCC.

Also HLCC might not work in the future. So alternatives to step 2 are:


Option 1: Use redistHelper.

I think it must be haxe-compiled from it’s location in your haxelib directory, before you can use it on projects. And I’m not yet sure if it runs on other windows machines without any haxe/hashlink/cl.exe environment.
See also the explanation page by Deepnight.


Option 2: Use MSVC/cl.exe.

cl.exe out\main.c /Fe:main.exe /Ox -I %hashlink%\include -I out %hashlink%\*.lib
pause

A sample command which I ran from x64 Native Tools Command Prompt for VS 2019. You go to your project’s directory using cd and then run the command or batch-file. Please see here.


GCC (MinGW-w64) ?

I tried using many different gcc-commands by now, none succeded. The best I could get is an 4.2 MB main.exe file which does nothing, no window, no trace("hello world") though run from command line - nothing.

gcc out/main.c -O3 -o main -std=c11 -I"out" -I"%hashlink%\include" -L"%hashlink%" -l:libhl.lib -l:hl.lib -l:directx.lib -l:sdl.lib -l:openal.lib -l:ssl.lib -l:ui.lib -l:uv.lib -l:fmt.lib -l:mysql.lib -l:sqlite.lib -ldbghelp -municode
pause

Also revisit the compiling guide by Yanrishatum for more information.
One of the comments also seems to explain how to get rid of the terminal window after compiling.
You can also direct message me in this forum or ask on the discord channel #Heaps.

1 Like