I know that KDevelop 4 was able to import CMake projects (hand written CMakeLists.txt not generated by KDevelop) ... but now after I installed ubuntu 18.04 it seems this is not possible anymore (the Project > Open/Import Project dialog simply refuse take CMakeLists.txt when I click on it )? Or I miss something?
I tried to run cmake .. -DCMAKE_EXPORT_COMPILE_COMMANDS
as described here but it refuse with error message:
prokop#s2-041:~/git/SimpleSimulationEngine/cpp/Build$ cmake .. -DCMAKE_EXPORT_COMPILE_COMMANDS
Parse error in command line argument: -DCMAKE_EXPORT_COMPILE_COMMANDS
Should be: VAR:type=value
CMake Error: No cmake script provided.
CMake Error: Problem processing arguments. Aborting.
EDIT
OK, so according to the advice below I run
cmake .. -DCMAKE_EXPORT_COMPILE_COMMANDS=ON
and now it generate compile_commands.json but I still cannot open it with KDevelope ... the Import Project dialog still shows everything gray and inactive (see screenshots below). Not sure if it matters that I run KDevelop under xubuntu 18.04 LTS (not Kubuntu) and Gnome-Flashback Desktop environment.
This should still work in KDevelop 5. There's no need to run cmake -DCMAKE_EXPORT_COMPILE_COMMANDS .., KDevelop will do it for you.
The version of KDevelop packaged in Ubuntu 18.04 is rather old and has many known bugs, please try the 5.4.2 AppImage and see if that resolves your problem.
You should put the path to your source (top-level CMakeLists.txt file) at the end of your command, after any options.
cmake -DCMAKE_EXPORT_COMPILE_COMMANDS=ON ..
Here is the command line syntax documentation.
Edit: As Tsyvarev points out, CMake specifically complains about your -D syntax, which is missing the assignment to ON.
Related
so I just downloaded wslusing the wsl --install command using PowerShell
now I'm trying to connect it to Clion which works
i cant add images so here is a link to it
but when i'm tying to build the project i get this error
"CMake Error at CMakeLists.txt:1 (cmake_minimum_required):
CMake 3.20 or higher is required. You are running version 3.16.3"
my cmake file:
cmake_minimum_required(VERSION 3.20)
project(ex2 C)
set(CMAKE_C_STANDARD 99)
add_executable(ex2
ex2.c ex2.h
main1.c
main2.c)
i tried updating wsl using wsl --update (in powershell)
The CMake installation inside the WSL is used. Unfortunately currently snap doesn't seem to be available in WSL, but installing the latest CMake version isn't too complicated nonetheless:
(optional) uninstall the old cmake installation in WSL; personally I don't see any benefit in multiple CMake installations, but there may be valid reasons for this. Most likely this will just makes the use of cmake more complex, since you need to remember which cmake version is used.
Download the appropriate cmake version from the cmake website ( https://cmake.org/download/ ). The version to choose is the tar.gz file under binary distributions for the x86_64 target. To get version 3.21.4 (currently the latest release), you can download the file from https://github.com/Kitware/CMake/releases/download/v3.21.4/cmake-3.21.4-linux-x86_64.tar.gz (Identical to the link on the CMake download page).
Unpack the archive from WSL. Navigate to the directory where you want the cmake installation to recide. This will add the cmake-3.21.4-linux-x86_64 directory containing all the files required to work with cmake to the current working directory. Let's assume you want to add the cmake files to the /opt directory. Furthermore let's assume the windows user name to be fabian, C: to be the primary hard drive and the download to be saved to the Downloads directory in the user directory:
cd /opt
tar -xf /mnt/c/Users/fabian/Downloads/cmake-3.21.4-linux-x86_64.tar.gz
(optional) make CMake available without specifying the path; this could be done as described here: https://unix.stackexchange.com/questions/3809/how-can-i-make-a-program-executable-from-everywhere ; don't do this, if an existing cmake installation is already available in the command line assuming you did install cmake to /opt, the cmake binary recides at /opt/cmake-3.21.4-linux-x86_64/bin
You should now be able to use cmake specifying either the full path to the executable (/opt/cmake-3.21.4-linux-x86_64/bin/cmake assuming you used the /opt directory) or directly via a command after opening the WLS commandline again (provided you followed step 4).
Now the only thing left to do should be telling CLion about the location of the cmake executable. Note that I haven't tested this, since I don't use this IDE. It's working fine using Visual Studio Code though...
I am really struggling to setup wxWidgets to work on Windows and CMake and would appreciate some help.
I have downloaded wxWidgets 3.1.4, run the setup (which extracted to C:\CPP_lib\wxWidgets) and then ran the following commands in the terminal:
cd C:\CPP_lib
mkdir wxWidgets-install
cmake C:\CPP_lib\wxWidgets -DCMAKE_INSTALL_PREFIX=C:\CPP_lib\wxWidgets-install -DwxBUILD_SHARED=OFF
cd wxWidgets-install
cmake --build . --target install
I have environment variables CMAKE_PREFIX_PATH set to C:\CPP_lib and wxWidgets_DIR and wxWidgets_ROOT_DIR both set to C:\CPP_lib\wxWidgets-install.
However, when I have a simple CMake project that calls find_package(wxWidgets), I get the following message in the terminal:
Found wxWidgets: winmm;comctl32;uuid;oleacc;uxtheme;rpcrt4;shlwapi;version;wsock32
missing components: core base png tiff jpeg zlib regex expat
Please help - I have been struggling for a while now :(
It turns out the issue was a very specific one related to vcpkg.
I had pointed CMake to my vcpkg toolchain file (even though wxWidgets was installed independent of vcpkg) and this was causing issues with finding wxWidgets i.e. vcpkg was preventing wxWidgets (a non-vcpkg installation) from being found.
I believe this is a vcpkg bug, although am not sure, but have reported it anyways.
I've been using Eclipse for a while now for java development and it is seamless. I considered using eclipse for C development also. I installed C/C++ IDE CDT 9.9 addon from the marketplace. I now can create a Makefile project and develop code. But, I'm not able to debug code. After some research, I understood that the native debugger CDT is integrated with, GDB is no longer shipped with macOS. So, at this point, I understood that I have two solutions:
Install GDB and everything works normally.
Install LLDB addon for Eclipse available at the marketplace and everything works normally.
I went on installing LLDB addon for Eclipse and when tried to debug, it showed me:
I checked it in the terminal and I found out that lldb is available and lldb-mi is not available. I googled it and found lldb-mi. To install lldb-mi as shown on the Github page, I needed to install CMake. When I try to generate build files for lldb-mi using CMake, it showed me:
After seeing this message, I thought I may need to install LLVM. I googled and found two ways:
Install from Homebrew
Compile and build from source code and install from it
I chose to go and compile the source code and install it. I downloaded llvm-9.0.0.src and generated build as instructed here. It took almost 2 hours and gave this error:
Now, as I understand it, I just generated build files(Makefiles) and compiled the LLVM source code. It's 19GB in size now. Should I go ahead and install it? or have I misinterpreted anything and did anything wrong?
As #Tsyvarev pointed out, using sudo, llvm got installed successfully. Now, lldb-mi needs to be installed. When I go back and cmake ., it's showing me this error:
Karthiks-MacBook-Pro:lldb-mi-master karthik$ sudo cmake .
-- Found LLVM 9.0.0
-- Using LLVMConfig.cmake in: /usr/local/lib/cmake/llvm
-- Building with -fPIC
CMake Error: The following variables are used in this project, but they are set to NOTFOUND.
Please set them or make sure they are set and tested correctly in the CMake files:
lib_lldb
linked by target "lldb-mi" in directory /Users/karthik/Downloads/lldb-mi-master/src
-- Configuring incomplete, errors occurred!
See also "/Users/karthik/Downloads/lldb-mi-master/CMakeFiles/CMakeOutput.log".
As #squareskittles pointed, I understood that lldb-mi requires lib_lldb for cmake to generate build files. I did:
$git clone https://github.com/lldb-tools/lldb-mi
$cd lldb-mi
$mkdir build
$cmake -DCMAKE_PREFIX_PATH=path/to/llvm/root/tree -S . -B build/
CMake should generate all the build files into lldb-mi/build/. It is successful.
$cd build
$make
make should compile the code. It produced:
Karthiks-MacBook-Pro:lldb-mi karthik$ cd build
Karthiks-MacBook-Pro:build karthik$ make
[ 1%] Building CXX object src/CMakeFiles/lldb-mi.dir/MICmdArgValListBase.cpp.o
In file included from /Users/karthik/buildspace/lldb-mi/src/MICmdArgValListBase.cpp:10:
/Users/karthik/buildspace/lldb-mi/src/MICmdArgValListBase.h:40:69: error: a space is required between consecutive right
angle brackets (use '> >')
: public CMICmdArgValBaseTemplate<std::vector<CMICmdArgValBase *>> {
^~
> >
1 error generated.
make[2]: *** [src/CMakeFiles/lldb-mi.dir/MICmdArgValListBase.cpp.o] Error 1
make[1]: *** [src/CMakeFiles/lldb-mi.dir/all] Error 2
make: *** [all] Error 2
Karthiks-MacBook-Pro:build karthik$
I put space between those > >, but there are still a lot of errors in the code.
I presume there are errors in the lldb-mi repository itself.
Can anyone tell me what I should be doing now?
Thanks in advance!
The lldb-mi not longer present from Xcode 11.x, but lldb and LLDB.Framework already included in the Xcode.
Use the lldb-mi that comes bundled with previous versions of XCode( 10.x) , the location is ‘Xcode.app/Contents/Developer/usr/bin/lldb-mi’, copy it to the same location of current version XCode.
And, in Eclipse, change the lldb command location.
Fine!
I downloaded CustusX from the homepage and tried to follow the build instructions. (with ./cxInstaller.py --full --all -t RelWithDebInfo as last command. That went smoothly on Kubuntu 14.04.
Now with everything checked out and available on the harddisk I tried to set up a project that such that I can do some debugging from within an IDE eg. qtcreator or eclipse. I searched the documentation but didn't find it there.
I tried to point cmake-gui at /[...]/custusx/CX/CX, chose Eclipse CDT4 - Ninja and tried to configure. But it fails since it cannot find FindEigen.cmake:
CMake Error at /usr/share/cmake-2.8/Modules/FindPackageHandleStandardArgs.cmake:108 (message):
Could NOT find Eigen (missing: EIGEN_INCLUDE_DIR EIGEN_VERSION_OK)
(Required is at least version "2.91.0")
Call Stack (most recent call first):
/usr/share/cmake-2.8/Modules/FindPackageHandleStandardArgs.cmake:315 (_FPHSA_FAILURE_MESSAGE)
CMake/FindEigen.cmake:76 (find_package_handle_standard_args)
CMake/cxInitializeLibraries.cmake:273 (find_package)
source/CMakeLists.txt:11 (cx_initialize_Eigen)`
I see there is a FindEigen.cmake in the CMake directory, but setting the CMAKE_MODULE_PATH didn't help either.
QtCreator didn't work either as it experiences the same problems parsing the CMake files when pointed at CMakeLists.txt at custusx/CX/CX
So, the question is how to get a running setup in an IDE preferable qtcreator or eclipse for developing custusx plugins?
CustusX is configured using the superbuild cxInstaller.py. As part of this build, cmake is invoked with parameters:
cmake arguments source_folder
An example when located in the build folder /home/cas/cx/CX/build_Release:
cmake -G"Eclipse CDT4 - Ninja" -DCMAKE_BUILD_TYPE:STRING=Release -DEIGEN_INCLUDE_DIR:PATH=/home/cas/cx/eigen/eigen -DCTK_DIR:PATH=/home/cas/cx/CTK/build_Release -DOpenCV_DIR:PATH=/home/cas/cx/OpenCV/build_Release ...more arguments omitted... /home/cas/cx/CX/CX
This command can be found by looking through the console output of cxInstaller.py, under the heading == configure CustusX ==. Once the superbuild is run once, you can start working with cmake-gui, QtCreator or Eclipse:
When using cmake-gui, set "Where to build the binaries" to your build folder. This will automatally cause the existing cmake configuration to be loaded. In your case, cmake-gui probably tried to configure from scratch, without arguments.
When using QtCreator, first open the root CustusX CMakeLists.txt file. This leads you to the "Configure Project" page. The cmake configuration must be added manually: Set the location of the build folder, then configure, which fails. Then, in "Project->Build Settings->CMake arguments", paste in all arguments that the superbuild (cxInstaller.py) sent to cmake, i.e. the cmake command line excluding cmake and source folder. If using ninja, you might have to configure that as well.
It seems like the current version of QtCreator (3.0.1, Ubuntu 14.04) do not read the cmake configuration of a project, requiring the procedure described above. This was not necessary with the version shipped with Ubuntu 12.04.
When using Eclipse, use "Import", then "General->Existing Projects into Workspace", select CX as root directory, when CustusX should appear as a project that can be imported directly (Caution: If you prevously configured using QtCreator, the Eclipse project files will have been deleted. Run the superbuild again)
How to set up QtCreator 3.0.1 (Not needed for other versions of QtCreator) on Ubuntu 14.04 for CustusX:
Get CMake arguments (with minimal output):
./install/cxInstaller.py --configure -t RelWithDebInfo CustusX
Search through the output for the (long) line starting with cmake and ending with ...cx/CX/CX
Paste in these arguments in Project->Build Settings->CMake arguments
I'm using Cmake to try to build a project for Eclipse. When I try running Cmake, I get the following error:
Error: could not load cache
Error: Batch build stopped due to Eclipse CDT4 - Unix Makefiles error.
---- Time Elapsed: 3 secs ----
Error: could not load cache
Error: Batch build stopped due to Eclipse CDT4 - Unix Makefiles error.
I'm completely stumped on what might be causing this. I know that I'm running Cmake in the correct directory and the CMakeCache.txt file is present. Could someone point me in the right direction to solve this?
If you are using the CLion, you can use File---"Reload CMake Project".
I meet this problem after using git force pull, and Reload CMake Project solves it.
Remove the CMakeCache.txt and try again. You probably had a bad cmake setup.
I have faced the same problem and solved it using the terminal.
Delete the cached/configurations files as we will get them again.
To configure the project run cmake .
Build the project using cmake --build .
run cmake --configure . it should generate required files.
I ran into this recently using JetBrains CLion and the above instructions were helpful but not directly, I was able to reload the project using the "cog" drop down in the CMake tab:
If you are absolutely positive that you are running the build command from the binary directory, this error probably means that you have had an issue during the configuration/generation step that you should have ran before trying the build. You can try to configure again to check (cmake your-build-dir)
I would advise running the Gui and trying to load the cache to see if you get a more explicit error (although I doubt it).
Another possibility would be to try to create a new clean build directory and take it from there.
In your example Eclipse must run something like
cmake --build folder_name --target all
and I opt that the *folder_name* is bad in this case. You probably messed something up in Eclipse.
For me it helps to select CMake tab (next to Run, TODO) in CLion. Then click the Reload CMakeProject button.
I got this error on Windows WSL with ubuntu
~/tmp/cmake$ cmake --build ./build
Error: could not load cache
I was able to fix the above error by running the following cmds in order:
% cmake -S . -B ./build
% cmake --build ./build
The above solution was derived from this post.
If you are using Visual Studio 2019, close Visual Studio, delete .vs and out folders then rebuild your project.
I removed the .cxx and other ide-generated files to the recycle.bin, except app.iml. Then I restarted Android Studio, and eventually it worked fine.
The solution that worked for me using VisualStudio 2017 was choosing:
CMake --> Cache --> Generate (from the top menu)
Apart from the already given answers, it might be due to the wrong commands or in wrong order.
To be precise, for me, it was due to
cmake -B build -G Ninja
cmake --build .
The "cmake --build ." command will throw the Could Not Load Cache error.
The problem is the build directory is given as '.' which doesn't have the cache or whatever files cmake generates, so correct command was 'cmake --build build'... and fixed !
There maybe trillion other ways but my solution was this.
For eg, it happened with the repo -> https://github.com/adi-g15/worldlinesim, though may show the same for other repos too.
For Ubuntu users, provide the source code open-pose path in the CMake-GUI.
P.S I had this issue and my path was not set there.
Most probably the issue is you have not wrote the correct name of the Visual Studio version you have installed during the build file preparation:
cmake .. -G "Visual Studio 16 2019" (note if you have VS 2016 you should change in in there)
The most realistic answer and personal experienced answer is
If you are using Clion and building files with IDE
And getting the error Cmake Error: could not load cache
Because you have accidentally deleted the cache file (like me: permanently and cant get back) or there is other problems or other problems
Then do this:
Run -> Clean
Run -> Build
And your project will be working all fine
cmake -B ./build(dest dir)
cmake --build ./build(