CMake error for OpenCV compilation in Windows - c++

I am trying to build the files in the "Source" folder to the "Build" folder using CMake in order to build OpenCV program in Eclipse. But I am facing the following error:
The C++ compiler "C:/MinGW/bin/g++.exe" is not able to compile a simple
test program. It fails with the following output:
Change Dir: C:/opencv/mbuild/CMakeFiles/CMakeTmp
Run Build Command:"C:/CMake/bin/cmake.exe" "cmTC_03910/fast"
CMake Error: The source directory
"C:/opencv/mbuild/CMakeFiles/CMakeTmp/cmTC_03910/fast" does not exist.
Specify --help for usage, or press the help button on the CMake GUI.
CMake will not be able to correctly generate this project.
Call Stack (most recent call first):
CMakeLists.txt:93 (project)
I have installed MinGW several times along with CMake also, but still getting the same error.
Please help me out!! Thanks in advance

As mentioned at this tutorial PyIMageSearch opencv install
if you are using opencv version 3.1 you should set
-D INSTALL_C_EXAMPLES=OFF \ instead ON
I solved problem with this way

Related

CMake error in CLion after updating CMake

I am relatively new to coding in C++ and using CMake. I have been writing code using CLion IDE on ubuntu 16.04. I had written a library, with an older version of CMake (I believe it was version 3.4) which came bundled with CLion and for an unrelated reason needed to update to version 3.15. Which I assume I must have done incorrectly.
When reloading Cmake projects that previously ran fine, I get the following error message:
Found Qt4: /usr/bin/qmake (found version "4.8.7")
CMake Error at cmake-build-debug/_deps/eigen-src/cmake/language_support.cmake:33 (file):
file failed to open for writing (Permission denied):
/home/majed/CLionProjects/TwoLink_manip/cmake-build-debug/language_tests/Fortran/CMakeLists.txt
Call Stack (most recent call first):
cmake-build-debug/_deps/eigen-src/test/CMakeLists.txt:19 (workaround_9220)
I have looked through a numeber of Cmake questions which I thought could be related to my issue but none of them seemed to address this specific issue. I am not very familiar with the Cmake installation and setup and simply followed a youtube tutorial to install the latest release(cmake-3.15.5-Linux-x86_64.sh)from the cmake.org site.
I should point out that CMake does work when I run ROS packages from the terminal which is why I am apprehensive about re-installing everything. I am assuming the issue is related to where the cmake file is installed but not sure how to fix this issue with CLion. I would appreciate any and all suggestions.
I have also tried to export CMAKE_ROOT to the locaton of the new cmake folder but it doesn't really have any effect.

Clion cmake in ubuntu 18.04

I've seen this one over and over but every answer that was given before didn't help me.
I downloaded clion and cmake, and updated gcc.
When manualy using gcc/g++ the code is compiling.
from the clion's cmake I keep getting:
CMake Error at /home/dm/Downloads/CLion-2018.1.4/clion-2018.1.4/bin/cmake/share/cmake-3.10/Modules/CMakeTestCCompiler.cmake:52 (message):
The C compiler
"/usr/bin/gcc"
is not able to compile a simple test program.
It fails with the following output:
Change Dir: /home/dm/CLionProjects/TheTestingGrounds/cmake-build-default/CMakeFiles/CMakeTmp
Run Build Command:"/usr/local/bin/cmake" "cmTC_9582b/fast"
CMake Error: The source directory "/home/dm/CLionProjects/TheTestingGrounds/cmake-build-default/CMakeFiles/CMakeTmp/cmTC_9582b/fast" does not exist.
Specify --help for usage, or press the help button on the CMake GUI.
CMake will not be able to correctly generate this project.
Thing is, the cmTC_9582b/fast obviously dosen't exist. What is clion trying to do? It looks like it's trying to test cmake with a bad test and when its failing Clion decideds there's a problem.
Any solution for that?

Ubuntu OpenCV not compiling

I'm trying to compile OpenCV 3.2 with contributions with the following commands:
1.
cmake -DCMAKE_BUILD_TYPE=Release -DBUILD_SHARED_LIBS=OFF -DCMAKE_INSTALL_PREFIX=/usr/local/ -DOPENCV_EXTRA_MODULES_PATH=/home/matteo/Desktop/Xilinx/OpenCV/source/opencv_contrib/modules/ /home/matteo/Desktop/Xilinx/OpenCV/source/opencv-3.2.0/
2.
make -j7 # runs 7 jobs in parallel
3.
sudo make install
Can you explain why I get
...
........
...........
........................
-- VTK is not found. Please set -DVTK_DIR in CMake to VTK build directory, or to VTK install subdirectory with VTKConfig.cmake file
-- Caffe: NO
-- Protobuf: NO
-- Glog: NO
-- Downloading ...
CMake Error at cmake/OpenCVUtils.cmake:1043 (file):
file DOWNLOAD cannot open file for write.
Call Stack (most recent call first):
../opencv_contrib/modules/dnn/cmake/OpenCVFindLibProtobuf.cmake:32 (ocv_download)
../opencv_contrib/modules/dnn/CMakeLists.txt:5 (include)
CMake Error at cmake/OpenCVUtils.cmake:1047 (message):
Failed to download . Status=
Call Stack (most recent call first):
../opencv_contrib/modules/dnn/cmake/OpenCVFindLibProtobuf.cmake:32 (ocv_download)
../opencv_contrib/modules/dnn/CMakeLists.txt:5 (include)
-- Configuring incomplete, errors occurred!
I'm working with Ubuntu 16.04 . I already had OpenCV on the system: maybe I unistall it in the wrong way? I remember to compile OpenCV 3.2 with the same command used above.
You must have matching versions of the opencv_contrib and the opencv itself.
Under the opencv github, go to the OpenCV releases and download the 3.2.0 (it should be the same in the master branch).
Now, go to https://github.com/opencv/opencv_contrib/releases and download the 3.2.0. Then you will have both versions matching.
After that all the cmake commands found on the README.md at opencv_contrib master branch should work fine.
I get the same error, that exact error, around the protobuf. There's another error on the xfeatures2d module, too, if your delete the dnn modules (so they don't get configured/built). My problem is, I need the "non-free" xfeatures2d module. :(
The problem appears to be in the opencv_contrib, in the DNN and xfeatures2d modules, but I'm not sure how to fix it. the call to ocv_download seems to be having empty inputs, even though the dnn and xfeatures2d cmake files are passing in arguments. I am not even a novice with cmake, so I'm not sure how to troubleshoot further.
I get this error on both Mac configuring for XCode and on Windows configuring for Visual Studio, using the latest version of cmake-gui, 3.8.0-rc3.
EDIT: I think I've found the issue, though. I opened an issue in the opencv_contrib github. There is a call to ocv_download in the dnn and xfeatures2d cmake files that uses FILENAME as the first parameter, but should be using PACKAGE instead. When I changed the parameters to PACKAGE, CMake successfully configured opencv with the opencv_contrib modules.
Hope this helps! :)
You might not use the same version of opencv and opencv_contrib
https://github.com/opencv/opencv_contrib/archive/<version>.zip
https://github.com/opencv/opencv/archive/<version>.zip
like master or 3.2.0
SHORT
You need to have the same version in opencv and opencv_contrib (.../opencv_contrib/modules/... belongs to an independent repo).
Either the same release or the last commit in BOTH repositories.
Check which version you have and move the other. In your case, I guess you have to change the version of opencv_contrib, then move to the release with git or download it from github.
git checkout <number_opencv_version i.e. 3.2.0>
LONG
I guess as Ken Lee, that you do not have the same version in the repositories.
As Matt referenced in the opened issue, there is a problem with the call of ocv_download because the version is not the one that was used when opencv-3.1, therefore it fails because the parameter is not the expected one.
It happens to me when I was using opencv 3.1.0 and the last version of opencv_contrib. You could change the cmake files one by one, but it is easier to take the correct version in each repo.
There is a right conflict in your build folder (may result from your previous sudo make install). I don't remember how I fixed it, but you can try recursively chown to both source and build folders (or chmod to 777).

fail to compile simple Opencv C++ file with CMake

Hi I am trying to run a simple C++ program with Opencv to display Image file but I am getting following error.
The imported target "opencv_core" references the file
"/usr/local/lib/libopencv_core.so.3.2.0"
but this file does not exist. Possible reasons include:
The file was deleted, renamed, or moved to another location.
An install or uninstall procedure did not complete successfully.
The installation package was faulty and contained
"/usr/local/share/OpenCV/OpenCVModules.cmake"
but not all the files it references.
Call Stack (most recent call first):
/usr/local/share/OpenCV/OpenCVConfig.cmake:111 (include)
CMakeLists.txt:3 (find_package)
-- Configuring incomplete, errors occurred!
The code for which is an example given in opencv here: http://docs.opencv.org/2.4/doc/tutorials/introduction/linux_gcc_cmake/linux_gcc_cmake.html#linux-gcc-usage
I tried to use opencv 3.2 before but I uninstalled n deleted all the opencv files using sudo apt-get remove libopencv*
I found similar question here: CMake does not find OpenCV but couldnt understand the answer. I have ROS Indigo installed on ubuntu 14.04.4. Also, I tried to install Opencv 2.4.13 but when I am checking the version installed using following command
pkg-config --modversion opencv
2.4.8
I am getting 2.4.8 and the main question why its referencing the file /usr/local/lib/libopencv_core.so.3.2.0 ?
FYI I installed opencv as per the instructions given here: http://docs.opencv.org/2.4/doc/tutorials/introduction/linux_install/linux_install.html#linux-installation
Thank you
So I figured it out, apparently I had linking problem because of bad instalment. I uninstalled opencv , deleted all the files and reinstalled it. I could have solved it using symlink as well but figured its best to clear everything and reinstall it. worked perfectly.
Additional note : Its my observation that if you have ROS installed and saved the opt/ros/indigo/setup.bash in ~/.bashrc , it will give errors so better remove those lines from ~/.bashrc and then try again.
any other suggestion ??
If you have more than one OpenCV installed in your computer, you could delete your OpenCV folder or you could move your folder to your temp folder:
sudo mv /usr/local/share/OpenCV /temp/OpenCV
It worked for me!!

Installing the SFGUI with Cmake

I've been trying to install SFGUI library with Cmake tool with instructions given here: SFGUI Install Tutorial . Still got many problems in major with Cmake, which couldn't find few files from SFGUI directory, for example
CMake Error: The source "D:/SFGUI-master/CMakeLists.txt" does not match the source "D:/SFGUI-0.3.0/CMakeLists.txt" used to generate cache. Re-run cmake with a different source directory.
Restarting didn't help. Could anyone write how to install this in simple steps? Regards.
cmake is telling you that the files it has generated in it's cache from a previous run don't match the source files you are currently using. I would imagine that you ran cmake, then switched git branches or tags and tried to run cmake again. You can just rm -r CMakeFiles in your build directory to remove the cache. Then you should be able to run cmake again without errors.
Thanks! It moved a little bit, but stopped actually at error:
CMake Error at cmake/Modules/FindSFML.cmake:306 (message):
Could NOT find SFML (missing: SFML_GRAPHICS_LIBRARY SFML_WINDOW_LIBRARY
SFML_SYSTEM_LIBRARY)
Call Stack (most recent call first):
CMakeLists.txt:21 (find_package)
Configuring incomplete, errors occurred!
See also "C:/Users/admin/Documents/Visual Studio 2015/Projects/sfml1/sfml1/CMakeFiles/CMakeOutput.log".
To be honest, I will write down steps I did: 1.Configured SFML in VS15 in Windows 8.1 2. I installed the newswet version of CMake 3. Installed also newest SFGUI from Github. 4.In Cmake GUI as a build I choose my project in VS and as a source - SFGUI directory. 5.In CMake Configure and there are the errors. Did I missed something?