fatal error: opencv2/core.hpp: No such file or directory compilation terminated in opencv4 - c++

In opencv4 while compiling code, I am getting this error:
fatal error: opencv2/core.hpp: No such file or directory
compilation terminated.
I properly installed opencv4.
Why am I getting an error?

Try installing the -dev or -devel package for OpenCV2 to get the header file.
sudo apt-get install libopencv-core-dev on Debian and Ubuntu, and sudo yum install opencv-devel on Fedora.
Once that's done, append $(pkg-config --cflags opencv) to your compiler command:
export CC="gcc $(pkg-config --cflags opencv)"

I know it's late but posting it here for future references.
If you're using OpenCv for Node.js with the npm package opencv4nodejs which in turn has a dependency on node-gyp, this error is expected when the package installation path contains whtespaces. node-gyp is known to not handle whitespaces well.
So, ideally the path shouldn't be something like this C:\Program Files\some_dir.
Try installing the package in a path without any whitespace and it should work.

Related

Boost cross compilation with custom Yocto SDK fails with "No such file or directory" errors

I've been given a custom Yocto SDK so as to build a c++ app I've created and the third party libraries that the app depends on.
I've installed the SDK on a VM Ubuntu 16.04.
The first library I needed to build was boost. I use version. 1.64.
I follow the same steps I follow each time to build boost either on a Yocto SDK or a default arm compiler.
$ . /opt/environment-setup-poky-linux-gnueabi
$ ./bootstrap.sh --with-libraries=filesystem,iostreams,program_options,regex,system --prefix=/home/user/Libs
$ nano ~/user-config.jam where I place the following commands
$ using gcc : arm : /opt/sysroots/x86_64-linux/usr/bin/arm-poky-linux-gnueabi/arm-poky-linux-gnueabi-g++ --sysroot= /opt/sysroots/arm-poky-linux-gnueabi ;
$ ./b2 install toolset=gcc-arm link=shared threading=multi
However I always get the following error :
gcc.compile.c++ bin.v2/libs/system/build/gcc-arm/release/threading-multi/error_code.o
In file included from /opt/sysroots/arm-poky-linux-gnueabi/usr/include/gnu/stubs.h:55,
from /opt/sysroots/arm-poky-linux-gnueabi/usr/include/features.h:452,
from /opt/sysroots/arm-poky-linux-gnueabi/usr/include/c++/8.2.0/arm-poky-linux-gnueabi/bits/os_defines.h:39,
from /opt/sysroots/arm-poky-linux-gnueabi/usr/include/c++/8.2.0/arm-poky-linux-gnueabi/bits/c++config.h:508,
from /opt/sysroots/amr-poky-linux-gnueabi/usr/include/c++/8.2.0/cstddef:49,
from ./boost/config/compiler/gcc.hpp:165,
from ./boost/config.hpp:39,
from ./boost/system/config.hpp:13,
from ./boost/system/error_code.hpp:14,
from libs/system/src/error_code.cpp:16:
/opt/sysroots/arm-poky-linux-gnueabi/usr/include/gnu/stubs-32.h:7:11: fatal error: gnu/stubs-soft.h: No such file or directory
# include <gnu/stubs-soft.h>
^~~~~~~~~~~~~~~~~~
I assume that the sysroot is not found correctly.
When I tried with a user-config.jam that does not contain --sysroot variable I get the error :
gcc.compile.c++ bin.v2/libs/system/build/gcc-arm/release/threading-multi/error_code.o
In file included from ./boost/config.hpp:39,
from ./boost/system/config.hpp:13,
from ./boost/system/error_code.hpp:14,
from libs/system/src/error_code.cpp:16:
./boost/config/compiler/gcc.hpp:165:10: fatal error: cstddef: No such file or directory
#include <cstddef>
^~~~~~~~~
compilation terminated.
The CC variable on the environment setup contains the follwoing:
export CC="arm-poky-linux-gnueabi-gcc -march=armv7ve -mfpu=neon -mfloat-abi=hard -mcpu=cortex-a7 --sysroot=$SDKTARGETSYSROOT"
Is there something I can do to bypass these errors or the SDK is faulty and needs rebuilt ?
Thanks in advance

fatal error: 'openssl/evp.h' file not found cmake + make

Operating system: macOS Catalina
I have a project that has a file called CMakeLists.txt. I ran cmake and then make, but the make command failed:
/Users/blablabla/Downloads/myproject/src/main.cpp:10:10: fatal error:
'openssl/evp.h' file not found
#include <openssl/evp.h>
I tried reinstalling OpenSSL via homebrew, linking the libraries but it still gave this error.
What am I could be doing wrong?
Any help would be highly appreciated
either openssl's dev library is not installed, or the g++ command that cmake generates probably is missing a -I.
try sudo apt-get install libssl-dev first and if that doesn't work, make sure the openssl include dir is provided to g++.
according to https://cmake.org/cmake/help/v3.6/module/FindOpenSSL.html, it creates an env var of OPENSSL_INCLUDE_DIR
edit: just noticed you're on OSX. you can install the the dev libssl package with brew install openssl

Qt error cannot find -lQtCore -lQtGui -lQtTest -QtOpenGl -lcore on linux ubuntu 16.04

I am using Qt 5.12.2 on a linux ubuntu 16.04 and when I execute a program I get an error saying that it is not finding -lQtCore, -lQtGui, -lQtTest, -lQtOpenGl and -lcore and I also get
collect2 error: ld returned 1 exit status.
What can i do to fix this?
I have already tried solving this using the command sudo apt-get install libglu1-mesa-dev and sudo apt-get install mesa-common-dev
It appears that you do not have the Qt5 libraries installed on your system. The libraries are included with the Qt Creator runtime, so it can always find them. When you run an executable outside of Qt Creator, you must (typically) copy the libraries required to the folder where the executable has been placed.
Check out the details in the docs.
https://doc.qt.io/qt-5/linux-deployment.html

Ubuntu Eclipse libxml2 error : fatal error: libxml/xmlversion.h: No such file or directory

I want to use libxml2 in my eclipse project. I can use this library on command line by "
g++ main.cpp -I/usr/include/libxml2 -lxml2 -o output
"
But I can't use on eclipse.I add C++ Build->Setting->GCC C Compiler->Includes
-I/usr/include/libxml2
and I add C++ Build->Setting->GCC C++ Linker->library
-lxml2
But When I build my project, I get an error via
libxml/parser.h:15:31: fatal error: libxml/xmlversion.h: No such file or directory
This is because libs are not complete. You should install them.
Here's one thread that might be helpful.
One solution:
sudo apt-get install libxml2-dev libxslt1-dev
For Redhat/Centos/Fedora:
yum install libxml-devel

error happens during installation of pyipopt in Ubuntu 12.04

having installed IPOPT and trying to install pyipopt in Ubuntu 12.04 box, I encountered the following error:
python setup.py install
results in the following error:
running install
running build
running build_py
running build_ext
building 'pyipoptcore' extension
gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fPIC -I/usr/lib/python2.7/dist-packages/numpy/core/include -I/usr/local/include/coin/ -I/usr/include/python2.7 -c src/callback.c -o build/temp.linux-x86_64-2.7/src/callback.o
In file included from src/callback.c:36:0:
src/hook.h:5:29: fatal error: IpStdCInterface.h: No such file or directory
compilation terminated.
error: command 'gcc' failed with exit status 1
any ideas ?
this is the interface for the ipopt library which is required to compile. as stated in the setup.py file
# You will probably have to edit this file in unpredictable ways
# if you want pyipopt to work for you, sorry.
the easiest way to handle this is to adjust the setup.py accordingly:
# When I installed Ipopt from source, I used the
# --prefix=/usr/local
# option, so this is where I want pyipopt to look for my ipopt installation.
# I only installed from source because the ipopt packaging
# for my linux distribution was buggy,
# so by the time you read this the bugs have probably been fixed
# and you will want to specify a different directory here.
IPOPT_DIR = '/usr/local/'
adjust IPOPT_DIR to the path where the library has been installed on your system, which of course should has been conducted anyway.
EDIT:
If you are installing from source, just use --prefix=/usr/local for the configure script and compile and install the library by running make; sudo make install. Then you don't have to change the setup.py file.