I have read the related questions but I cannot solve my problem.
I'm trying to compile a OpenCV C++ code on raspberry pi.
OpenCV requires cv.h to be included. When I try to compile I get:
"fatal error: cv.h: No such file or directory."
I have tried these:
g++ -c -Ihome/pi/OpenCV-2.3.1/include/opencv file.cpp
g++ -c -Ipi/OpenCV-2.3.1/include/opencv file.cpp
g++ -c -IOpenCV-2.3.1/include/opencv file.cpp
Do any of you have any ideas?
This is a general question and not related only to OpenCV.
For the general problem of including any header file
1. Try to see if the file is really at the included directory or no
2. Try to look for it in the folder
Related
I am trying to install NetCDF with PGI. However, to do so, I first need to install zlib and when I try to do that, I do:
export C_INCLUDE_PATH=/the/path/to/include/:$C_INCLUDE_PATH
export PATH=/the/path/to/compilers/bin/:$PATH
Then I try:
CC=pgcc CXX=pgc++ ./configure --archs="x86_64"
I get the following error:
Building shared library libz.so.1.2.11 with pgcc.
Checking for size_t... No.
Checking for long long... Yes.
Failed to find a pointer-size integer type.
** ./configure aborting.```
The **configure.log** says, among other things:
```pgcc -c -O3 x86_64 ztest212261.c
ztest212261.c:
"/usr/include/stdio.h", line 183: error: attribute "__malloc__" does not take arguments
__attribute_malloc__ __attr_dealloc_fclose __wur;
Can someone give me a hint on this?
Thank you in advance.
In order to compile netcdf-c and their dependencies, you need to not only link the include path but also lib path. So you need to do something like
export C_INCLUDE_PATH=/the/path/to/include/:$C_INCLUDE_PATH
export LD_LIBRARY_PATH=/the/path/to/lib/:$LD_LIBRARY_PATH
export PATH=/the/path/to/compilers/bin/:$PATH
And for the configuration, you also need to set CFLAGS and such.
I want to use gcc in docker/singularity image to compile a program. Using local gcc, I use gcc tc.c -I PATH_TO_LIB without any error. To use the gcc in the image, I use the following command line.
singularity exec gcc_5.1.0.sif gcc tc.c -I PATH_TO_LIB
But the problem is that gcc cannot find the .h file in the library path. It returns the following error.
fatal error: csmith.h: No such file or directory
#include "csmith.h"
When compiling demo OpenCV code, such as,
g++ HoughLines_Demo.cpp `pkg-config opencv --cflags --libs` -o HoughLines_Demo,
the compiler cannot find the header files:
HoughLines_Demo.cpp:7:33: fatal error: opencv2/imgcodecs.hpp: No such file or directory
#include "opencv2/imgcodecs.hpp"
^
If I downloaded opencv-3.0.0 correctly, these header files do exist on my computer already, right? If so, what do I need to do to link them correctly?
The exact error message:
Running:
Ubuntu 14.04,
g++-4.8,
4.8.4-2 ubuntu1~14.04
Update:
Looking up this problem more, the problem should be outdated OpenCV code. I ran pkg-config --modversion opencv which returned 2.4.8. I could have sworn I was running 3.0.0 . What is going on here?
I am trying to build the OpenCV samples which come with the source package and I get the following:
CMake Error at CMakeLists.txt:10 (ocv_check_dependencies):
Unknown CMake command "ocv_check_dependencies".
I did install OpenCV using
cmake .
make
sudo make install
and I got a tutorial snippet working (thus I suppose it is installed correctly as a library). However, compiling the samples does not work.
I guess I have to somehow configure CMake to have “ocv_check_dependencies” - but how? I am lost!
Actually for OpenCV 2.4.4 beta the root CMakeList.txt file says:
OCV_OPTION(BUILD_EXAMPLES "Build all examples"
-DBUILD_EXAMPLES=ON worked just fine for me.
I got it.
In order to build the samples one has to change the default configuration for cmake by providing it via -D. What I did wrong was that I tried to execute cmake from within the samples directory.
The proper way to build the samples is invoking cmake like so (from within the root directory of the unpacked archive):
cmake -DBUILD_SAMPLES .
which will turn samples ON. One can proceed using make, make install than. The samples can be found in bin after building.
See also FAQ
How to compile OpenCV sample code ?
# For OpenCV 3
cd /path/to/opencv/samples/cpp/
#Compile
g++ -ggdb `pkg-config --cflags --libs opencv` facedetect.cpp -o facedetect
#run
./facedetect
Works for me.
googled from this link
mydragonisland's build instructions almost worked for me; with a minor reordering and including accents:
g++ facedetect.cpp -o facedetect `pkg-config --libs opencv`
The macro 'ocv_check_dependencies' is defined in: your_path_to/opencv/cmake/OpenCVModule.cmake
# ensures that all passed modules are available
# sets OCV_DEPENDENCIES_FOUND variable to TRUE/FALSE
macro(ocv_check_dependencies)
set(OCV_DEPENDENCIES_FOUND TRUE)
foreach(d ${ARGN})
if(d MATCHES "^opencv_[^ ]+$" AND NOT HAVE_${d})
set(OCV_DEPENDENCIES_FOUND FALSE)
break()
endif()
endforeach()
endmacro()
The top level CMakeLists.txt contains 'include' commands for files from opencv/cmake/ . Which is why the macro is available when you compile by calling cmake from the root of the opencv sources.
Reason
error message context:
CMake Error at CMakeLists.txt:10 (ocv_check_dependencies):
Unknown CMake command "ocv_check_dependencies".
This error message happens because cmake can't find the definition of ocv_check_dependencies
That's why the console said Unknown CMake command
Solution
If cmake cannot find where ocv_check_dependencies is defined
Just like #Nick Hockings Said:
ocv_check_dependencies is a macro defined in Your/OpenCV/path/OpenCVModule.cmake
macro(ocv_check_dependencies)
set(OCV_DEPENDENCIES_FOUND TRUE)
foreach(d ${ARGN})
if(d MATCHES "^opencv_[^ ]+$" AND NOT HAVE_${d})
set(OCV_DEPENDENCIES_FOUND FALSE)
break()
endif()
endforeach()
endmacro()
The fastest way is to copy this snippet above to your CMakeList.txt file right above where ocv_check_dependencies is
Therefore, cmake can finally understand what it is
That should do the trick, i hope no one else will bother with this question in the future
I got similar errors. My approach is as following:
1) cd xxx/samples 2) mkdir build 3) cd build 4) cmake .. 5) make
Now it works. We could not build individual project under their source files.
Following steps works for me.
Export toolchain path.
cd opencv-3.3.0/samples
cross_cmake &&
cross_make
cd opencv-3.3.0/samples/cpp/
When I try to build Assimp by running build_ios.sh, it tells me:
CMake Error: your C compiler: "/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/llvm-gcc" was not found. Please set CMAKE_C_COMPILER to a valid compiler path or name.
CMake Error: your CXX compiler: "/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/llvm-g++" was not found. Please set CMAKE_CXX_COMPILER to a valid compiler path or name.
What I need the path to be is:
/Applications/XCode.app/Contents/Developer/Platforms/...
I've tried changing DEVROOT in build_ios.sh and IPHONE_xxxx_TOOLCHAIN.cmake, because that's what CMAKE_C_COMPILER etc seem to get generated from, but it still gives me the same errors.
Option 1:
You can set CMake variables at command line like this:
cmake -D CMAKE_C_COMPILER="/path/to/your/c/compiler/executable" -D CMAKE_CXX_COMPILER "/path/to/your/cpp/compiler/executable" /path/to/directory/containing/CMakeLists.txt
See this to learn how to create a CMake cache entry.
Option 2:
In your shell script build_ios.sh you can set environment variables CC and CXX to point to your C and C++ compiler executable respectively, example:
export CC=/path/to/your/c/compiler/executable
export CXX=/path/to/your/cpp/compiler/executable
cmake /path/to/directory/containing/CMakeLists.txt
Option 3:
Edit the CMakeLists.txt file of "Assimp": Add these lines at the top (must be added before you use project() or enable_language() command)
set(CMAKE_C_COMPILER "/path/to/your/c/compiler/executable")
set(CMAKE_CXX_COMPILER "/path/to/your/cpp/compiler/executable")
See this to learn how to use set command in CMake. Also this is a useful resource for understanding use of some of the common CMake variables.
Here is the relevant entry from the official FAQ: https://gitlab.kitware.com/cmake/community/wikis/FAQ#how-do-i-use-a-different-compiler
The cc and cxx is located inside /Applications/Xcode.app. This should find the right paths
export CXX=`xcrun -find c++`
export CC=`xcrun -find cc`
SOLUTIONS
Sometimes the project is created before installing g++. So install g++ first and then recreate your project. This worked for me.
Paste the following line in CMakeCache.txt:
CMAKE_CXX_COMPILER:FILEPATH=/usr/bin/c++
Note the path to g++ depends on OS. I have used my fedora path obtained using which g++