Vscode with Lix extension - compile to cpp

this week I first installed the vscode Lix extension and I think it’s fantastic. So easy to set up a haxe project. This should really be advertised more, as way to start with haxe.

But I can’t get c++ compilation to work. Is this not supported yet or a bug?

This are the steps I did.
removed my previous haxe installation to have a fresh start
haxe and haxelib are no longer recognized in the terminal

In vscode
Haxe: Initialise Project
The message appears “Path to Haxe executable is not valid: ‘haxe.exe’. Please check your settings.” That’s ok because I don’t have haxe installed.

Lix: Initialise Project
I selected “local”

Now I can compile the Hello World example. Great!

When I change the build.hxml to cpp compilation
–cpp bin
The compilation process hangs.
I also tried to install hxcpp with Lix. Still doesn’t work.
Anybody else knows more about this?


I’m glad you like it!

I’ve actually had some issues getting lix to work with hxcpp as well. However, for me it doesn’t hang, it just prints a “Library hxcpp is not installed” error. So far I thought it might be something with lix itself, not the lix extension… But it actually seems to work fine when compiling from the command line (npx haxe build.hxml).

Perhaps there’s some unfortunate interaction between how the Haxe extension’s VSCode build tasks work and how lix works… I seem to remember talking about process vs shell tasks with somebody (@kevinresol?)

1 Like

I had the “Library hxcpp is not installed” error when Haxe and hxcpp were already installed on the system and I added the lix stuff later to the project. (by Lix: Initialise Project)

It seems there were some issues with lix and hxcpp in the past. lix-hxcpp repo. So they could be resolved by now.

“npx haxe build.hxml” works for now.

Thank You :slight_smile:

I seem to remember talking about process vs shell tasks with somebody

Hm, looks like using a vscode.ShellExecution for tasks instead of vscode.ProcessExecution doesn’t help much either, so I’m not really sure what’s going on…

Does it work if you run the build in command line instead of running through the extension?

p.s. make sure you have run lix +lib hxcpp beforehand

What is this magic? Doesn’t seem to be documented on the command line help…

It is a shorthand for install haxelib

Yeah, I started working on some configurable command expansion, but never got around to finish it, so for now there’s a few hard coded ones ^^

Yes, the build in commandline works. I get an error message but it compiles anyway.

BTW, this is the error message:

> npx haxe build.hxml
      throw er; // Unhandled 'error' event

Error: EPIPE: broken pipe, write
    at Socket._write (internal/net.js:58:25)
    at doWrite (_stream_writable.js:415:12)
    at writeOrBuffer (_stream_writable.js:399:5)
    at Socket.Writable.write (_stream_writable.js:299:11)
    at haxeshim_HaxelibCli.path (D:\Projects\Haxe\cpp\test_lix\node_modules\lix\bin\haxelibshim.js:8266:18)
    at haxeshim_HaxelibCli.dispatch (D:\Projects\Haxe\cpp\test_lix\node_modules\lix\bin\haxelibshim.js:8305:9)
    at haxeshim_HaxelibCli.main (D:\Projects\Haxe\cpp\test_lix\node_modules\lix\bin\haxelibshim.js:8231:49)
    at Object.tink_core__$Callback_Callback_$Impl_$.invoke (D:\Projects\Haxe\cpp\test_lix\node_modules\lix\bin\haxelibshim.js:10154:3)
    at tink_core_FutureTrigger.handle (D:\Projects\Haxe\cpp\test_lix\node_modules\lix\bin\haxelibshim.js:10424:42)
    at tink_core__$Future_SimpleFuture.f (D:\Projects\Haxe\cpp\test_lix\node_modules\lix\bin\haxelibshim.js:10416:13)
Emitted 'error' event at:
    at errorOrDestroy (internal/streams/destroy.js:107:12)
    at onwriteError (_stream_writable.js:430:5)
    at onwrite (_stream_writable.js:461:5)
    at Socket._write (internal/net.js:62:14)
    at doWrite (_stream_writable.js:415:12)
    [... lines matching original stack trace ...]
    at haxeshim_HaxelibCli.main (D:\Projects\Haxe\cpp\test_lix\node_modules\lix\bin\haxelibshim.js:8231:49)
haxelib run hxcpp Build.xml haxe -Danalyzer-optimize="1" -Danalyzer_optimize="1" -Dhaxe="4.0.0-rc.3" -Dhaxe3="1" -Dhaxe4="1" -Dhaxe_ver="4.000" -Dhxcpp_api_level="400" -Dhxcpp_smart_strings="1" -Dsource-header="Generated by Haxe 4.0.0-rc.3+e3df7a448" -Dstatic="1""cpp" -Dtarget.static="true" -Dtarget.sys="true" -Dtarget.threaded="true" -Dtarget.unicode="true" -Dtarget.utf16="true" -Dutf16="1" -I"src/" -I"" -I"C:\\Users\\Next\\AppData\\Roaming/haxe/versions/4.0.0-rc.3/std/cpp/_std/" -I"C:\\Users\\Next\\AppData\\Roaming/haxe/versions/4.0.0-rc.3/std/"
Creating D:/Projects/Haxe/cpp/test_lix/bin/obj/msvc19xp/__pch/haxe/hxcpp.pch...

I was able to reproduce this on the command line, it looks like it has to do with vshaxe calling haxe.cmd directly:

1 Like

Ok, this should finally work now. Turns out there were two separate issues, one in vshaxe (fixed in 2.18.0), and one in haxeshim (the EPIPE one mentioned here, fixed in lix 15.8.5).


Works for me, too. :smiley: