CMake could not find OpenCV library like cv.h - opencv

I'd wanted to run the project in Ubuntu PC, but I received an error.
When I ran the following code;
make
And, There is a error in following;
asiye#asiye:~/Desktop/cmfd_framework/build$ make
Consolidate compiler generated dependencies of target common
[ 8%] Built target common
[ 10%] Building CXX object ground_truth_db/CMakeFiles/cmfdgt.dir/command_ground_truth.cpp.o
/home/asiye/Desktop/cmfd_framework/ground_truth_db/command_ground_truth.cpp:10:10: fatal error: cv.h: No such file or directory
10 | #include "cv.h"
| ^~~~
compilation terminated.
make[2]: * [ground_truth_db/CMakeFiles/cmfdgt.dir/build.make:76: ground_truth_db/CMakeFiles/cmfdgt.dir/command_ground_truth.cpp.o] Error 1
make[1]: * [CMakeFiles/Makefile2:205: ground_truth_db/CMakeFiles/cmfdgt.dir/all] Error 2
make: * [Makefile:91: all] Error 2
I think Cmake could not find OpenCV library but why ?
Could you explain to me if there is another way to address this problem?
Best Regards,

Cmake Dosyası burada Yunus Temurlenk
CMakeLists.txt
cmake_minimum_required(VERSION 2.6)
project(Vole)
set(Vole_CMFD ON)
set(Vole_CMFD_Ground_Truth ON)
set(Vole_Shell ON)
set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake")
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
include(VoleHelperMacros)
include(VoleModuleMacros)
if(WIN32)
add_definitions(-DNOMINMAX) # prevents min- and max-macro brainf*ck in VS 2003
endif(WIN32)
# Global options
option(VOLE_CMAKE_DEBUG_OUTPUT "Show additonal cmake debug output." OFF)
mark_as_advanced(VOLE_CMAKE_DEBUG_OUTPUT)
option(VOLE_CHECK_DEPENDENCIES "Do additional dependency check with nice error messages." ON)
mark_as_advanced(VOLE_CHECK_DEPENDENCIES)
option(VOLE_SINGLE_TARGETS "Build single targets for each command." OFF)
set(VOLE_MODULE_DIRECTORIES "" CACHE STRING "Semicolon-separated list of module directories for vole, e.g. the forensics or the color code.")
# maybe there is a better place for these two options:
option(Boost_NO_SYSTEM_PATHS "Suppress searching in system paths or other locations outside of BOOST_ROOT." OFF)
set(BOOST_ROOT "" CACHE STRING "The preferred installation prefix for searching for Boost. Set this if the module has problems finding the proper Boost installation.")
# Global variables
set(VOLE_PACKAGE_LIST "" CACHE INTERNAL "Package list" FORCE)
set(VOLE_EXTERNAL_SUBDIRECTORIES "" CACHE INTERNAL "External subdirectories" FORCE)
set(VOLE_MODULE_LIST "" CACHE INTERNAL "Module list" FORCE)
include(VoleFindPackages)
# include(VoleFindExternalModules)
add_subdirectory(common core/common)
include_directories(common shell cmfd ground_truth_db)
add_subdirectory(cmfd cmfd)
add_subdirectory(ground_truth_db ground_truth_db)
add_subdirectory(shell core/shell)
include(VoleCheckDependencies)
INCLUDE("CMakeModules/TargetDoc.cmake" OPTIONAL)

Related

How to fix error with CMake while installing LuaDist on Windows 10

I've been trying to install Luadist, but an error with CMake always happens and in the end it doesn't install because of it.
This seems to be a common issue on Windows 10. I've followed the instructions from https://github.com/LuaDist/Repository/wiki/LuaDist%3A-Installation and https://github.com/LuaDist/Repository/wiki/Installation-of-System-Dependencies#microsoft-windows . I've tried uninstalling it and installing it again, but it didn't work. I tried installing Lua on the same drive as LuaDist, but it still doesn't work. I think the error might be because I also have LuaRocks installed, I don't know if they are compatible together.
[ 37%] Performing configure step for 'luafilesystem'
loading initial cache file C:/Users/User/_bootstrap/_bootstrap/tmp/config.cmake
CMake Error at C:/Program Files (x86)/CMake/share/cmake-3.15/Modules/CMakeMinGWFindMake.cmake:12 (message):
sh.exe was found in your PATH, here:
C:/Program Files/Git/usr/bin/sh.exe
For MinGW make to work correctly sh.exe must NOT be in your path.
Run cmake from a shell that does not have sh.exe in your PATH.
If you want to use a UNIX shell, then use MSYS Makefiles.
Call Stack (most recent call first):
CMakeLists.txt:7 (project)
CMake Error: CMAKE_C_COMPILER not set, after EnableLanguage
-- Configuring incomplete, errors occurred!
CMakeFiles\luafilesystem.dir\build.make:106: recipe for target 'luafilesystem/src/luafilesystem-stamp/luafilesystem-configure' failed
mingw32-make.exe[3]: *** [luafilesystem/src/luafilesystem-stamp/luafilesystem-configure] Error 1
CMakeFiles\Makefile2:114: recipe for target 'CMakeFiles/luafilesystem.dir/all' failed
mingw32-make.exe[2]: *** [CMakeFiles/luafilesystem.dir/all] Error 2
CMakeFiles\Makefile2:175: recipe for target 'CMakeFiles/install.dir/rule' failed
mingw32-make.exe[1]: *** [CMakeFiles/install.dir/rule] Error 2
Makefile:156: recipe for target 'install' failed
mingw32-make.exe: *** [install] Error 2
## Bootstrap done, building LuaDist using LuaDist
'C:\Users\User\_bootstrap\_bootstrap\bin\luadist.exe' is not recognized as an internal or external command,
operable program or batch file.
## LuaDist is now built and can be found in C:\Users\User\_bootstrap\_install
At the end it says that LuaDist is built in C:\Users\User_bootstrap_intall , but that folder doens't exist after the installation.

Adding Library to CMake on CLI

I'm trying to build OpenCV with CUDA support using Arch Linux's AUR. In their build configuration some options are passed to CMake, I have modified those to add CUDA features. Upon attempting compilation I get the following error:
[ 10%] Built target pch_Generate_opencv_reg
In file included from /home/meurer/Downloads/opencv-git/src/modules/cudacodec/opencv_cudacodec_pch_dephelp.cxx:1:0:
/home/meurer/Downloads/opencv-git/src/opencv/modules/cudacodec/src/precomp.hpp:59:14: fatal error: dynlink_nvcuvid.h: No such file or directory
#include <dynlink_nvcuvid.h>
^~~~~~~~~~~~~~~~~~~
compilation terminated.
make[2]: *** [modules/cudacodec/CMakeFiles/opencv_cudacodec_pch_dephelp.dir/build.make:63: modules/cudacodec/CMakeFiles/opencv_cudacodec_pch_dephelp.dir/opencv_cudacodec_pch_dephelp.cxx.o] Error 1
make[1]: *** [CMakeFiles/Makefile2:6834: modules/cudacodec/CMakeFiles/opencv_cudacodec_pch_dephelp.dir/all] Error 2
I searched my filesystem and found the rogue header file in /usr/include/nvidia-sdk/dynlink_nvcuvid.h. Due to how AUR works, I believe I can only configure CMake via command line options (See links 1, 2 under _cmakeopts=...).
What argument can I pass to CMake to make it search for the appropriate libraries under the aforementioned directory, as well as the ones it already uses?

openCV error while configuring via cmake

I am trying to visualize the data using ASAP. While configuring it in cmake, I am getting this error. OpenCV is already installed in my ubuntu system in the folder /usr/local/share.
opencv_calib3d opencv_core opencv_features2d opencv_flann opencv_highgui opencv_imgcodecs opencv_imgproc opencv_ml opencv_objdetect opencv_photo opencv_shape opencv_stitching opencv_superres opencv_video opencv_videoio opencv_videostab opencv_viz
This red line probably comes from the line 3 of ASAP/imgproc/CMakeLists.txt.
The message() macro is used without any flag. This produce an "Important information" message displayed in red in cmake-gui, but in this case, it's not an error. Maybe ASAP developpers should have used STATUS mode to print some debug information from CMake script:
message(STATUS ${OpenCV_LIBRARIES})
Maybe you could send a pull request.

CMake OpenCV 3.0.0 and building executables and libraries in Ubuntu

I have OpenCV 3.0.0 installed in /usr/local/opencv-3.0.0
I am trying to construct a CMakeLists file to build a library against this OpenCV 3.0.0. The CMakeLists.txt is as follows:
cmake_minimum_required(VERSION 2.8)
project(STT_People_Tracker)
cmake_policy(SET CMP0016 NEW)
# compilation mode setup
#set(CMAKE_BUILD_TYPE Release)
set(CMAKE_BUILD_TYPE Debug)
# set OpenCV directories - CHANGE DEPENDING ON SYSTEM
set(OpenCV_PATH "/usr/local/opencv-3.0.0")
set(OpenCV_INCLUDE_DIRS "${OpenCV_PATH}/include")
set(OpenCV_LIBS "${OpenCV_PATH}/lib/")
# set environment variables
set(SOURCES_PATH "${CMAKE_SOURCE_DIR}/Sources")
set(INCLUDES_PATH "${SOURCES_PATH}/include")
if(CMAKE_BUILD_TYPE MATCHES Debug)
set(OUTPUT_PATH "../Debug")
message(STATUS "Compiling in DEBUG mode")
elseif(CMAKE_BUILD_TYPE MATCHES Release)
set(OUTPUT_PATH "../Release")
message(STATUS "Compiling in RELEASE mode")
endif()
include_directories(${INCLUDES_PATH})
include_directories(${OpenCV_INCLUDE_DIRS})
# compilation of executables
message(STATUS "configuring executables...")
add_executable(${OUTPUT_PATH}/mainTest ${SOURCES_PATH}/mainTest.cpp)
# compilation of libraries
message(STATUS "configuring libraries...")
add_library(${OUTPUT_PATH}/background_substractor ${SOURCES_PATH}/background_substractor.cpp)
# set linker options
link_directories(${OpenCV_LIBS})
target_link_libraries(${OUTPUT_PATH}/mainTest opencv_core opencv_highgui)
target_link_libraries(${OUTPUT_PATH}/background_substractor opencv_core opencv_highgui)
message(STATUS "cmake configuration complete")
It is a fairly simple Cmake file, however, I have the following problems/doubts:
1.-How can I know I am using OpenCV 3, and not other versions of OpenCV present in the system?
2.- When compiling the file background_substractor, its associated header file can not be located, although I have checked the path and it is correctly assigned in the set(INCLUDES_PATH "${SOURCES_PATH}/include"):
/home/alberto/STT_People_Tracking/Sources/background_substractor.cpp:3:36: fatal error: background_substractor.h: No such file or directory
#include "background_substractor.h"
^
compilation terminated.
make[2]: *** [CMakeFiles/../Debug/background_substractor.dir/Sources/background_substractor.cpp.o] Error 1
make[1]: *** [CMakeFiles/../Debug/background_substractor.dir/all] Error 2
make: *** [all] Error 2
3.- Finally, and if I comment the header file, I have problems linking:
Linking CXX static library lib../Debug/background_substractor.a
/usr/bin/ar: lib../Debug/background_substractor.a: No such file or directory
make[2]: *** [lib../Debug/background_substractor.a] Error 1
make[1]: *** [CMakeFiles/../Debug/background_substractor.dir/all] Error 2
make: *** [all] Error 2
I have tried everything: Specifying the include files in the add_executable() and add_library() commands, I have checked paths and they are ok, etc etc.
Could anyone more experienced with CMake, give me a little hand?
Thank you very much in advance,
Alberto
How can I know I am using OpenCV 3, and not other versions of OpenCV present in the system?
Your project should check that.
But usually projects just use find_package command for fill variables related to 3d-party library. This command perform all needed checks. In your case it could be
find_package(OpenCV 3 REQUIRED)
call, which fills OpenCV_LIBS and OpenCV_INCLUDE_DIRS variables automatically. This command, by default, search OpenCV installation in default paths, but you can adjust searching algorithm by using parameters to cmake (so, you needn't to change CMakeLists.txt when you build the project on other machine). E.g., this way
cmake -DOpenCV_DIR=/usr/local/opencv-3.0.0 <source-dir>
you can specify precise installation path of OpenCV.
When compiling the file background_substractor, its associated header file can not be located...
Cannot suggest anything aside from checking file existence
/home/alberto/STT_People_Tracking/Sources/include/background_substractor.h
But this also can be a result of the 3d issue(see below).
Finally, and if I comment the header file, I have problems linking...
Your usage of CMake targets is incorrect. Unlike to make targets, which usually are files, CMake targets are simple names. By default, name of library/executable target determines filename of the library/executable file, produced by this target, but this can be changed. Directory, where resulted file will be located, can be adjusted using CMAKE_<TYPE>_OUTPUT_DIRECTORY variables, where <TYPE> can be ARCHIVE, LIBRARY or RUNTIME depending on target type.
Correct CMake script would be:
cmake_minimum_required(VERSION 2.8)
project(STT_People_Tracker)
cmake_policy(SET CMP0016 NEW)
# compilation mode setup
#set(CMAKE_BUILD_TYPE Release)
set(CMAKE_BUILD_TYPE Debug)
# set OpenCV directories using find_package.
find_package(OpenCV 3 REQUIRED)
# set environment variables
set(SOURCES_PATH "${CMAKE_SOURCE_DIR}/Sources")
set(INCLUDES_PATH "${SOURCES_PATH}/include")
if(CMAKE_BUILD_TYPE MATCHES Debug)
set(OUTPUT_PATH "${CMAKE_BINARY_DIR}/Debug") # Use absolute path
message(STATUS "Compiling in DEBUG mode")
elseif(CMAKE_BUILD_TYPE MATCHES Release)
set(OUTPUT_PATH "${CMAKE_BINARY_DIR}/Release")
message(STATUS "Compiling in RELEASE mode")
endif()
# Set output directory for STATIC libraries and executables
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${OUTPUT_PATH})
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${OUTPUT_PATH})
include_directories(${INCLUDES_PATH})
include_directories(${OpenCV_INCLUDE_DIRS})
# compilation of executables
message(STATUS "configuring executables...")
add_executable(mainTest ${SOURCES_PATH}/mainTest.cpp) # Use simple name as a target
# compilation of libraries
message(STATUS "configuring libraries...")
add_library(background_substractor ${SOURCES_PATH}/background_substractor.cpp) # Use simple name as a target
# set linker options
# Command below is no-op: OpenCV libraries enumerated using absolute paths
# link_directories(${OpenCV_LINK_DIRECTORIES})
target_link_libraries(mainTest ${OpenCV_LIBS}) # Variable OpenCV_LIBS contains OpenCV libraries needed to link with
target_link_libraries(background_substractor ${OpenCV_LIBS})
message(STATUS "cmake configuration complete")

c++ in MonoDevelop: clang: error: no input files

I have a question that is probably trivial, but I can't see the solution now. I have a .cpp file that I would like to run through MonoDevelop. Unfortunately, instead of a small Bantumi simulation, I only get:
Building Solution: Bantumi (Debug)
Building: Bantumi (Debug)
Performing main compilation...
Precompiling headers
Compiling source to object files
Generating binary "Bantumi" from object files
g++ -o "/Users/myname/Projects/Bantumi/Bantumi/bin/Debug/Bantumi"
clang: error: no input files
Build complete -- 1 error, 0 warnings
---------------------- Done ----------------------
Build: 1 error, 0 warnings
From what I found, most people had this problem when there was no such file in the current directory, or the compiler did not have a valid address. However, my file is exactly where the compiler looks for it, but it still produces an error. Do you know what else could lead to this error message?
Thanks a lot! If this type of question has already been solved, you can just send me a link to it.

Resources