VSCode with Msys2 / Mingw64 on Windows ( With Guide )

Hi there,

I’m trying to setup of on VSCode but I can’t find a solution for the error I get while trying to compile (build debug or build release):

Compiling OF library for Debug
/usr/bin/sh: -c: line 2: syntax error: unexpected end of file
make[2]: *** [makefileCommon/compile.core.mk:233: C:/Users/mmang/Desktop/of_v0.11.2_msys2_mingw64_release/libs/openFrameworksCompiled/lib/msys2/obj/Debug/.compiler_flags] Error 2
make[1]: *** [makefileCommon/compile.core.mk:212: Debug] Error 2
make: *** [C:/Users/mmang/Desktop/of_v0.11.2_msys2_mingw64_release/libs/openFrameworksCompiled/project/makefileCommon/compile.project.mk:139: Debug] Error 2

The code compiles and runs in the MSYS shell, so I can edit it in VSCode and run it from the shell but it’s kind of annoying and I’m sure it’s something small that could fix it, I just don’t know what.

If someone could help me out it would be amazing!

This post tells how to integrate minsys shell with VS Code.

1 Like

@Matteo_Mangoni did the link @mpcseal share work for you? If so we should add some documentation for it to the download/setup page on the site.

Going to turn this into a setup guide - but thought I would add here too.

Using VS Code on Windows with msys2 / mingw64.

Note we recommend using the nightly builds of OF from the bottom of the downloads page. The nightly builds have VS Code project files included for all examples.

Step 1: Follow the msys2 setup guide. Using Mingw64.

Step 2: Make sure you have the C:\mingw64 location in your PATH.
setx PATH "c:\msys64\mingw64\bin;c:\msys64\usr\bin;%PATH%"

Step 3: Open a Mingw64 shell, cd to the examples folder eg: cd /C/Users/theo/Downloads/OF/examples/3d/assimpExample folder and try building an example with make Release.

If you it compiles successfully you have a working msys2 / Mingw64 setup.

Step 4: Install VS Code.
Download from: https://code.visualstudio.com/

Step 5: Edit the VS Code Settings to use Mingw64 as your default shell.

{
    "terminal.integrated.shell.windows": "C:\\msys64\\usr\\bin\\bash.exe", 
    "terminal.integrated.shellArgs.windows": ["--login", "-i"],
    "terminal.integrated.env.windows": { 
         "MSYSTEM": "MINGW64", 
         "CHERE_INVOKING":"1" } 
}

Step 6: Close VS-Code and reopen.
Then open the example VS Code project file for the OF example you want to run. For assimpExample it is: assimpExample.code-workspace.

Step 7: Install the C++ extension if VS Code asks.

Step 8: Build your project.
In the VS Code menu go to TerminalRun Build Task.... and select Build Release

If everything is working you should see successful complication in the Terminal output window.

5 Likes