I have setup with build directory set to ./bin within source root.
Everything works until I change ./bin to symbolic link.
Then everything configures correctly but make starts complaining about not found source files:
make[2]: *** No rule to make target '../cpp/foo.cpp', needed by 'CMakeFiles/mylib.dir/cpp/foo.cpp.o'.
Why it happens and what could I do about it?
I had idea to convert this path to absolute (inside makefile) and dump it to console in order to figure-out where it points to but it turned out that this "build.cmake" is recreated automatically at every make invocation :(
Thanks to Tsyvarev I realized that it is unmovable OS constraint with potential workaround using mount bind
I needed to do the same on a Mac (to exclude the build directory from iCloud Drive) and had success with executing the cmake-command from the build directory (not going there via link) and giving the absolute path for the source to cmake.
See also: https://stackoverflow.com/a/24435795/4883924
Visual Studio Code cannot find the g++ command of my MinGW(btw, intelliSense has no problem because I have set c_cpp_propertites.json correctly). Any idea? Thanks in advance, the following is the output:
Executing task: g++ -g helloworld.cpp
g++ : The term 'g++' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
What happened to me was that VSC didn't automatically source my PATH. After I added g++, closed and reopened it, the issue was solved.
I'm having a similar issue and I believe I've narrowed it down to being due to "g++" being your command. Check your task config file and note what you have set for "command".
"command" is what the task is going to try and run along with whatever arguments you have stipulated which in your case I assume is "-g" and "helloworld.cpp".
Now, what I'm having trouble determining is why it isn't finding g++ as if I try to compile a source file via a command prompt I have no issue and it compiles successfully.
Looking through the documentation for VS code I did find a way to reference your environment variables in the task config: {env:Path} will serve as prefix for my User environment variable "Path" which has a reference to c:\Mingw\lib\bin (note this is an accurate path, simply an example). I think we're pretty close to getting it to work it's just a matter of pathing to g++. My next attempt I think I will simply change "command" to reference an absolute path to g++.
Step 1 - Copy your path of bin file of your mingw compiler (eg. C:\Program Files\mingw-w64\x86_64-8.1.0-posix-seh-rt_v6-rev0\mingw64\bin)
Step 2 - Go to properties by right clicking 'This PC' button.
Step 3 -
Step 4 -
Step 5 -
Step 6 -
If this not work, try this again from beginning.
The temporary solution for this problem is as follows :---
Open VsCode in Run as administrator .
And set your tasks.json as follows. For ex :-- If your file name is main.cpp
It will build the file without error.
I've just had the same problem. Adding the \mingw\bin folder to my PATH variable didn't help. Running g++ in a cmd or PS window worked without a problem so it seems like VSCode is having problems reading or resolving the PATH variable.
To bypass this problem I've included the complete path to g++.exe in the command property of my task. After saving the task, VSCode was able to build my .cpp file.
{
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
"version": "2.0.0",
"tasks": [
{
"label": "build g++",
"type": "shell",
"command": "C:\\mingw-w64\\x86_64-8.1.0-posix-seh-rt_v6-rev0\\mingw64\\bin\\g++.exe",
"args": ["-g", "-o", "${fileBasenameNoExtension}", "${fileBasename}"],
"group": {
"kind": "build",
"isDefault": true
}
}
]
}
Search Path in windows search box
click on Environment Variables
Click on Path and hit Edit
Go to C: Drive and look for MinGW folder
then go to bin folder and copy the path
Create a New variable and paste the path and move it to the top
after that hit ok and restart your terminal/vs code to make it work again.
I've fixed this issue by adding the path to the bin of mingw-w64 to the windows path by typing setx path into the windows command prompt.
setx path "%path%;PATHTOBIN"
It would likely return that the PATH has been truncated to 1024 bits, in which case I edited the path variable directly in the register:
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Environment
Open your tasks.json and launch.json. Make sure that the "preLaunchTask" in launch.json is set to the same string value as the "label" of one the object in the tasks array in the tasks.json file.
launch.json file
tasks.json file
first, you need to make sure you have added the
C:\MinGW\bin
in the environment variable if you using windows environment
After installing MinGW, restart VS Code. The program will definitely execute.
Well, I also faced this problem and I tried every single method but it didn't work properly. But then I did this and it worked.
In Environmental variables under SYSTEM VARIBALES create a VARIABLE named CLASSPATH and VARIABLE VALUE as <path to MinGW> by clicking NEW in SYSTEM VARIABLES
'$' I had similar problem with vsc.
For me worked out:
1) Making(Remaking) system variable path to C:\MinGW\bin.
2) in c_cpp_properties.json adding:
"browse": {"path": ["${workspaceFolder}","C:\\MinGW\\lib\\gcc\\mingw32\\8.2.0\\include\\c++"]}
Edit the system environment variable ==> Environment variable.. ==>system variable ==>Click Path ( or Select Path + edit) ==> New paste C:\MinGW\bin ==> Ok
add the compiler path in the file c_cpp_properties.json as the following
"compilerPath": "C:/MinGW/bin/g++.exe",
it was working for me(add the path with respect to yout g++ exe from your mingw directory) ..
For me, closing and reopening VS Code without changing anything solved my problems.
Follow instructions given here for the C/C++ programming With VS code
After that if you still get this error that is after instaling MinGW.
Just close the VS code, and open it again.
Everything will fine.
I have a project under CMake with some files generated with python generator from XML files. I cannot specify all files generated by this generator in CMakeLists.txt so I use file globbing for this.
The problem is that when I update my XML files or generator sources (which are in the same repository) I would like to have my build system reconfigured so changed files are taken into account when rebuilding the code (via make for example).
Is it possible to make CMake treat some files like it treats CMakeLists.txt files and to make it regenerate build system when those file are changed?
It doesn't require any kind of workarounds. The standard way is to use CMAKE_CONFIGURE_DEPENDS property:
set_property(DIRECTORY APPEND PROPERTY CMAKE_CONFIGURE_DEPENDS <filename>)
Yes, you should be able to do that by (ab)using configure_file(). Configuring a file makes the source a dependency of the CMake run, so that any changes in it cause a reconfiguration. Simply like this:
configure_file(MyInputFile.xml DummyOutput.xml)
Since it has been a while I will add to #roolebo's answer.
There's actually a better command to add a dependency on a file:
set_directory_properties(PROPERTIES CMAKE_CONFIGURE_DEPENDS <relative_or_full_path_to_file>)
What might be confusing is that this command adds a property to the current directory. Well, it does not matter since you can set a full path to a file that resides outside of the current directory's scope, for instance: ../../config.json
I am trying to set up an environment for Component Pascal.
I chose the JVM option. I set a new system variable JROOT and added to the Path variable.
I try to run a new file I created via command line and got this error:
Error: Could not find or load main class CP.gpcp.gpcp
You must set a CPROOT environment variable to the instalation path of GPCP, something like
CPROOT=$HOME/gpcp;export CPROOT;
then add the bin directory to the GPCP executables to the PATH,
PATH=$CPROOT/bin:$PATH;export PATH;
both, in your .bashrc
Compile your CP program with
cprun gpcp <program>.cp
and execute with
cprun <program>
We're having problems when trying to deploy a number of projects which use zc.buildout - specifically we're finding that they want to put their PYTHON_EGG_CACHE directories all over the show. We'd like to somehow set this directory to one at the same level as the built-out project, where eggs can be found.
There is some mention online that this can be done for Plone projects, but is it possible to do this without Plone?
Are there some recipes that can set up an environment variable so we can set the PYTHON_EGG_CACHE executable files in ./bin?
The PYTHON_EGG_CACHE is only used for zipped eggs, your best bet is to have zc.buildout install all required eggs unzipped:
[buildout]
...
unzip = true
If your system python has zipped eggs installed that still require unzipping for resource access, and setting the PYTHON_EGG_CACHE in your scripts is your only option (as opposed to setting the environment variable for your user), you could try to use the initialization option of zc.recipe.egg to add arbitrary Python code to your scripts:
[a-part]
recipe = zc.recipe.egg
...
initialization =
import os
os.environ['PYTHON_EGG_CACHE'] = '/tmp/python_eggs'
I'm not sure what you mean. Three options that you normally have:
Buildout, by default, stores the eggs in a directory called eggs/ inside your buildout directory.
You can set the eggs-dir variable inside your buildout.cfg's [buildout] section to some directory. Just tell it where to place them.
You can also set that very same option in .buildout/defaults.cfg inside your home directory. That way you can set a default for all your projects. Handy for storing all your eggs in one place: that can save a lot of download time, for instance.
Does one of those (especially the last one) accomplish what you want?
And: don't muck around with eggs in the generated bin/* files. Let buldout pick the eggs, that's its purpose.