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

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

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

How to cross-compile C++ file

I have installed package for arm cross-compiling
sudo apt install -y build-essential gcc-arm-linux-gnueabi
If I compile hello.c file, it works perfectly
arm-linux-gnueabi-gcc hello.c
If I use hello.cpp file, it gives error
arm-linux-gnueabi-gcc hello.cpp
It shows following error
arm-linux-gnueabi-gcc: error trying to exec 'cc1plus': execvp: No such file or directory
please help me.
Install g++-arm-linux-gnueabi:
sudo apt install -y g++-arm-linux-gnueabi
and call arm-linux-gnueabi-g++ instead:
arm-linux-gnueabi-g++ hello.cpp

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

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.

How to Install Wt into a Custom Folder Without "fatal error: Wt/WApplication: No such file or directory"

I'm new to Wt and c++ and I just installed the Wt webframework on Ubuntu 16.04 LTS into a custom folder in my home directory. I cannot install or build any software into the /usr diretories of this computer. Even if I could, the PPA hasn't been active for 2 1/2 years, and the official Ubuntu installation instructions are also outdated. Aptitude no longer ships with Ubuntu and will eventually be discontinued.
I compliled and installed everything successfully, yet when I try to compile the Hello World example I get the following error:
g++ -o hello hello.cpp -lwt -lwthttp
fatal error: Wt/WApplication: No such file or directory
Here are my installation steps:
Boost:
wget https://dl.bintray.com/boostorg/release/1.65.1/source/boost_1_65_1.tar.bz2
tar --bzip2 -xf boost_1_65_1.tar.bz2
cd boost_1_65_1
./bootstrap.sh --prefix=../myfolder
sudo ./b2 install --prefix=../myfolder
CMake:
wget https://cmake.org/files/v3.9/cmake-3.9.2.tar.gz
tar -xvzf cmake-3.9.2.tar.gz
cd cmake-3.9.2
./configure --prefix=../myfolder
make
sudo make install
vim .profile
export PATH=$PATH:/home/ubuntu/myfolder/bin
Wt:
git clone https://github.com/emweb/wt.git
cd wt
cmake -DCMAKE_INSTALL_PREFIX:PATH=../myfolder .
-- Generating done
-- Build files have been written to: /home/ubuntu/myfolder
make
sudo make install
make -C examples
Since I'm lumping everything together in /myfolder I did not use the /build folder per the Wt installation instructions. The libwt and libboost libraries are in /myfolder/lib. I assumed all of the linking was taken care of during installation.
Any thoughts? Thanks in advance.
You have to tell your compiler to look for includes and libraries in the right folders, so instead of:
g++ -o hello hello.cpp -lwt -lwthttp
Try:
g++ -o hello hello.cpp -I/home/ubuntu/myfolder/include -L/home/ubuntu/myfolder/lib -lwt -lwthttp
Note that when you run your application, you'll also have to make sure that it can find the dynamic libs (.so files) it needs. You could do this:
export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:/home/ubuntu/myfolder/lib"

virtualenv python-ldap install error

Please don't call this a duplicate.
All the answers have so far only 'solved' the problem by installing the ldap and other development packages globally, which doesn't solve the problem of not being able to install the python-ldap package in the virtual environment.
Examples include:
How do I install python-ldap in a virtualenv on Ubuntu?
sudo apt-get install libsasl2-dev python-dev libldap2-dev libssl-dev
I am using ubuntu 14.04, python 2.7 and flask in my virtual environment.
When I run pip install python-ldap, I receive the following error.
copying Lib/ldap/schema/__init__.py -> build/lib.linux-x86_64-2.7/ldap/schema
copying Lib/ldap/schema/models.py -> build/lib.linux-x86_64-2.7/ldap/schema
copying Lib/ldap/schema/subentry.py -> build/lib.linux-x86_64-2.7/ldap/schema
copying Lib/ldap/schema/tokenizer.py -> build/lib.linux-x86_64-2.7/ldap/schema
copying Lib/ldap/syncrepl.py -> build/lib.linux-x86_64-2.7/ldap
file Lib/ldap.py (for module ldap) not found
file Lib/ldap/controls.py (for module ldap.controls) not found
file Lib/ldap/extop.py (for module ldap.extop) not found
file Lib/ldap/schema.py (for module ldap.schema) not found
running egg_info
writing requirements to Lib/python_ldap.egg-info/requires.txt
writing Lib/python_ldap.egg-info/PKG-INFO
writing top-level names to Lib/python_ldap.egg-info/top_level.txt
writing dependency_links to Lib/python_ldap.egg-info/dependency_links.txt
warning: manifest_maker: standard file '-c' not found
file Lib/ldap.py (for module ldap) not found
file Lib/ldap/controls.py (for module ldap.controls) not found
file Lib/ldap/extop.py (for module ldap.extop) not found
file Lib/ldap/schema.py (for module ldap.schema) not found
reading manifest file 'Lib/python_ldap.egg-info/SOURCES.txt'
reading manifest template 'MANIFEST.in'
warning: no files found matching 'Makefile'
warning: no files found matching 'Modules/LICENSE'
writing manifest file 'Lib/python_ldap.egg-info/SOURCES.txt'
running build_ext
building '_ldap' extension
creating build/temp.linux-x86_64-2.7
creating build/temp.linux-x86_64-2.7/Modules
x86_64-linux-gnu-gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fPIC -DHAVE_SASL -DHAVE_TLS -DHAVE_LIBLDAP_R -DHAVE_LIBLDAP_R -DLDAPMODULE_VERSION=2.4.21 -IModules -I/usr/include -I/usr/include/sasl -I/usr/local/include -I/usr/local/include/sasl -I/usr/include/python2.7 -c Modules/LDAPObject.c -o build/temp.linux-x86_64-2.7/Modules/LDAPObject.o
Modules/LDAPObject.c:18:18: fatal error: sasl.h: No such file or directory
#include <sasl.h>
^
compilation terminated.
error: command 'x86_64-linux-gnu-gcc' failed with exit status 1
----------------------------------------
Command "/home/kmertig/hd_request/hd_request/bin/python -c "import setuptools, tokenize;__file__='/tmp/pip-build-V4vhsl/python-ldap/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-NIR67Y-record/install-record.txt --single-version-externally-managed --compile --install-headers /home/kmertig/hd_request/hd_request/include/site/python2.7/python-ldap" failed with error code 1 in /tmp/pip-build-V4vhsl/python-ldap
If I try to pip install any of the suggested dev libraries so that they are inside my virtual environment, I get the following error.
Could not find a version that satisfies the requirement libsasl2-dev (from versions: ) No matching distribution found for libsasl2-dev
I can install all this stuff globally just fine, but that just plain defeats the purpose of using virtualenv.
I would really like to find a meaningful, virtualenv solution, since all I have been able to find is non-virtualenv solutions for a virtualenv question.
Thanks.
The Python package python-ldap requires some other libs (libsasl2-dev, …) which are not python libs (so you can't use pip to install them). So, to use them, you have to install them. Two solutions:
use your package manager to install them (ex.: apt-get) ;
download their source code and compile them locally (in your virtualenv) (useful for some libs in special cases).
Maybe you can try the second solution?