Using oF with VsCode on windows

I believe there might be an issue with the current version of oF which I have installed from the nightly build as the other build has an error while building,

I have installed v20230405_msys2_mingw64_nightly and have successfully followed the instructions provide to install using msys2 found here

After completing everything, I then ran the script located in C:/of/scripts/mysys2 called buildAllExamples.sh

This works! No problems whatsoever, I can even run the example applications just by double clicking them which(I believe) means that my path variables are all setup properly.

However I have encountered a tricky issue that I cannot find the solution for. My Build Tasks do not work.

  • I firstly created a project using the ProjectGenerator with the Advanced options tick enabled and selected the template Visual Studio Code and generated a project named testSketch2 I then opened the project from the testSketch2.code-workspace file that was created inside of C:/of/apps/myApps/testSketch2

After launching I proceeded to the next steps as detailed below:

  • I created a terminal profile for MSYS and set it to default which does work I went through this forum post to find that this was needed and have move away from the deprecated method shown, and instead created a new terminal profile for MSYS bash.

However when I run the build task: Build DEBUG I get the following output:

 *  The terminal process "C:\msys64\usr\bin\bash.exe '--login', '-i', '-c', 'make Debug -j -s 2>&1 || exit 1'" terminated with exit code: 1. 
 *  Terminal will be reused by tasks, press any key to close it.

When running Build RELEASE I get the following:

 *  Executing task in folder testSketch2: make -j -s 2>&1 && make RunRelease 

make: *** No targets specified and no makefile found.  Stop.

 *  The terminal process "C:\msys64\usr\bin\bash.exe '--login', '-i', '-c', 'make -j -s 2>&1 && make RunRelease'" terminated with exit code: 2. 
 *  Terminal will be reused by tasks, press any key to close it. 

if I launch MYSY64 and navigate to C:\of\apps\myApps\testSketch2 and run “make” I get the following output:

Sam@DESKTOP-I3MCUMR MINGW64 /c/of/apps/myApps/testSketch2
$ make
find: ‘C:of/libs/openFrameworksCompiled/project/msys2/config.*.mk’: No such file or directory
Compiling OF library for Release
make[1]: Entering directory '/c/of/apps/myApps/testSketch2'
make[1]: *** C:of/libs/openFrameworksCompiled/project/: No such file or directory.  Stop.
make[1]: Leaving directory '/c/of/apps/myApps/testSketch2'
make: *** [C:\of/libs/openFrameworksCompiled/project/makefileCommon/compile.project.mk:125: Release] Error 2

Similarly if I try and run make Debug iwth or without the args in tasks.json I get the following output:

Sam@DESKTOP-I3MCUMR MINGW64 /c/of/apps/myApps/testSketch2
$ make Debug -j -s 2>&1
find: ‘C:of/libs/openFrameworksCompiled/project/msys2/config.*.mk’: No such file or directory
Compiling OF library for Debug
make[1]: *** C:of/libs/openFrameworksCompiled/project/: No such file or directory.  Stop.
make: *** [C:\of/libs/openFrameworksCompiled/project/makefileCommon/compile.project.mk:139: Debug] Error 2

I believe the error lies in the output of running make, as you can see in the following line:

make[1]: *** C:of/libs/openFrameworksCompiled/project/: No such file or directory.  Stop.

make is attempting to access the folder, however, the C: does not include a / and thus does not exist?

Also something else I have seen is that in my c_cpp_properties.json under the Win32 tree there are several included paths that are not present in my current project, I believe this may just be libraries only required if you use addons with the ProjectGenerator? I am not sure, I have attached a screen capture of all the libraries underlined indicating they are necessary. I do not believe that this is what is causing my earlier problem, but I think providing all potentially relevant information is important.

Can anyone perhaps point me towards what I may have done wrong or potential fixes? Thank you!

Edit: Something I think is interesting which I have just tested is that if I create a folder called 1testing(to make it execute first) and then copy the testSketch2 file into this new folder and run ./buildAllExamples.sh the build succeeds and runs. Here is the output below incase it might be needed:

Sam@DESKTOP-I3MCUMR MINGW64 /c/of/scripts/msys2
$ ./buildAllExamples.sh
Building All Examples
=================================================================
category 1testing
=================================================================
Building 1testing/testSketch2
[Success]
-----------------------------------------------------------------

=================================================================
category 3d
=================================================================
Building 3d/3DModelLoaderExample

I canceled the script after reaching this point and have tested the generated exe file and it is working as expected.

Hmm.
That is weird.

Adding @oxillo as he is the msys2 ninja.
@oxillo do the current nightly builds work for you?

Also adding @dimitre as there is a chance something got borked with the of::filesystem changes in the PG which affects make.

For the c_cpp_propertiies issue the paths ../../../libs/cairo/ etc should exist.

If you look in:
of/libs/boost/
of/libs/cairo/
etc is there an include and a lib folder?

@awesamdude

I just tried a clean install on my PC and it worked fine building and running the examples with make.

Could you try downloading the nightly again from:

And in a mingw64 shell going into examples/3dPrimtiveExample/
and doing: make Release && make RunRelease

If that works for you fine but doing the same in app made with the projectGenerator it could be an issue with the PG.

Thanks!

yes it can be some issue in PG.
@awesamdude can you please repeat the projectGenerator creating and copy and paste here the output in Success! window after creation? something like

[notice ] -----------------------------------------------
[notice ] setting OF path to: /Volumes/tool/ofw
[notice ] from -o option
[notice ] target platform is: osx
[notice ] updating project /Volumes/tool/ofw/apps/myApps/mySketch
[notice ] saving addons.make
[notice ] project updated! 
[notice ] -----------------------------------------------


1 project updated [notice ] in 0.033093 seconds





(command used: "/private/var/folders/mf/y34npyxn787ftq1kvtx6x7tc0000gp/T/AppTranslocation/68BE029E-EFF4-4094-9945-F080A50E9F1D/d/projectGenerator.app/Contents/Resources/app/app/projectGenerator"  -o"/Volumes/tool/ofw" -a" " -p"osx" -t"" "/Volumes/tool/ofw/apps/myApps/mySketch")


can confirm here @dimitre

Project generated with PG has incorrect path but Examples work fine.

Here’s the output of PG:

[notice ] -----------------------------------------------
[notice ] setting OF path to: C:\Users\designiopc\Downloads\of_v20230405_msys2_mingw64_release
[notice ] from -o option
[notice ] target platform is: msys2
[notice ] project path is: C:\Users\designiopc\Downloads\of_v20230405_msys2_mingw64_release\apps\myApps\mySketch2
[notice ] setting up new project C:\Users\designiopc\Downloads\of_v20230405_msys2_mingw64_release\apps\myApps\mySketch2
[notice ] saving addons.make
[notice ] project created! 
[notice ] -----------------------------------------------


1 project created [notice ] in 0.0455566 seconds

(command used: "C:\Users\designiopc\Downloads\of_v20230405_msys2_mingw64_release\projectGenerator\resources\app\app\projectGenerator"  -o"C:\Users\designiopc\Downloads\of_v20230405_msys2_mingw64_release" -a" " -p"msys2" -t"" "C:\Users\designiopc\Downloads\of_v20230405_msys2_mingw64_release\apps\myApps\mySketch2")

Looking at the config.make of the project I think the issue might be that it is setting the OF_ROOT as absolute instead of relative like the examples.

One fix would be to get OF_ROOT working with windows absolute paths ( might be good anyway ). Another would be to convert to linux paths.

Probably the best fix is to make OF_ROOT a relative path if its inside of the OF Folder - that way if someone moves their OF folder things still work. I think that’s how it it used to work?

btw @awesamdude a quick fix for now is to comment out the line in config.make ( in your project folder ) which lists the OF_ROOT with the absolute path.

so for me changing:

OF_ROOT = C:\Users\designiopc\Downloads\of_v20230405_msys2_mingw64_release

to

#OF_ROOT = C:\Users\designiopc\Downloads\of_v20230405_msys2_mingw64_release

1 Like

Thank you for all the help @theo after following your instructions on changing the OF_ROOT line in config,make I can successfully build and run applications build from project generator and the examples as you mentioned previously.

However regarding this:

I still have many missing dependencies I will include a screenshot, on the previous screenshot I had changed some of the earlier includes to paths that actually did exist and were present to remove the squiggle but this is what they currently show for me with a clean install and a fresh project from PG:


My libs folder however does not include any of the files you have mentioned before let alone /include or /libs I have attached a screenshot of my /c/of/libs folder in the replies as I am limited to only one embedded image per post currently for reference.

The first two underlined items can be fixed by referencing the current versions that were installed with scripts/msys2/install_dependencies.sh however, the files at the bottom do not exist in my of/libs/ folder.

I believe I could potentially point them to the msys64 install of them s this is what make does when building and that succeeded, but it seems like this is an issue with PG? I am not sure, any direction would be much appreciated as VSCode is still unusable at this state with OF.

Here is my /c/of/libs/ folder for reference.

Ahh okay @awesamdude
I think your libs/ folder is correct.

The paths are in there for other platforms like osx - but because msys2 has more of the libs installed at the system level those are unused and missing in VS Code.

If you are able to build via Build Tasks in VS Code without modification you can just ignore. :slight_smile:

Edited Context.

Thank you @theo wanted to give an update on where I am at now that I have had some time to look at this today:

If I update everything inside of c_cpp_properties to something that actually does exist and contains the mentioned libraries as show below all the missing things do go away here. However this is obviously very hacky and I believe is not resolving the issue because I have copied the contents of the 3d/3DPrimitivesExample/ into ofApp.cpp and you can see the following issues in the image below for lots of references not being seen by intellisense.

I can however build this project from msys64 and it runs successfully. I still receive the same error when running the build from VSCode as follows:

 *  The terminal process "C:\msys64\usr\bin\bash.exe '--login', '-i', '-c', 'make Debug -j -s 2>&1 || exit 1'" terminated with exit code: 1. 
 *  Terminal will be reused by tasks, press any key to close it. 

This however is of much less importance to me than fixing my intellisense as building from mysys64 commandline now works. Guidance on fixing this link between VSCode and oF would be much appreciated.

I have marked this as the solution as it has allowed me to build my oF projects on windows and edit the code on VSCode, however still open that running the build tasks from VSCode does not work as intended. However I believe this to be with weird behavior between msys64 and VSCode not oF.

Hmm - did you check that you have your environment variables set?
setx PATH "c:\msys64\mingw64\bin;c:\msys64\usr\bin;%PATH%"

If that worked correctly you should see them in the Environment Variables → PATH ( hit windows key and type Environment Variables to bring it up ).

1 Like

For intellisense, I think you should add c:\msys64\mingw64\include in the search paths. This is where all system includes are.
If you are using mingw32 or ucrt64, you should update to c:\msys64\mingw32\include or c:\msys64\ucrt64\include accordingly.

1 Like

For the Build Task, I have this in my settings.json. The last line seems important.

"terminal.integrated.profiles.windows": {
        "PowerShell": {
            "source": "PowerShell",
            "icon": "terminal-powershell"
        },
        "Command Prompt": {
            "path": [
                "${env:windir}\\Sysnative\\cmd.exe",
                "${env:windir}\\System32\\cmd.exe"
            ],
            "args": [],
            "icon": "terminal-cmd"
        },
        "Git Bash": {
            "source": "Git Bash"
        },
        "MSYS2":{
            "path": "C:\\N\\msys64\\usr\\bin\\bash.exe",
            "label": "MSYS2",
            "args": ["--login", "-i"],
            "env": {
                "MSYSTEM": "MINGW64",
                "CHERE_INVOKING": "1",
                "MSYS2_PATH_TYPE": "inherit"
            }
        }
    },
    "terminal.integrated.defaultProfile.windows": "MSYS2",
1 Like

Thank you @theo and @oxillo for following up. I believe that all the issues I was having have now been resolved!

I believe the intellisense was acting was strangely because my search path was incorrect as described here:

Lastly the thing which I believe fixed the issues with the Run BuildTasks was solved due to this:

part of the configuration.

Thank you all so much for help in getting everything setup within openFrameworks!

For others having the same problem the full solution is to follow what @theo said here:

I am not sure, but maybe someone can shed light on when this fix will make it’s way into ProjectGenerator?

Lastly make sure the settings.json for VSCode found at %appdata%/Roaming/Code/User is updated to include the args and env sections as shown by @oxillo here: