How to cross-compile C++ file - c++

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

Related

Getting error while installing memsql python library "_mysql.c:44:10: fatal error: 'my_config.h' file not found" on MAC OSx

When am trying to install the memsql python library getting below error
I have tried the below options already:
sudo pip install memsql
sudo pip install memsql --global-option=build_ext --global-option="-I/usr/local/opt/openssl/include" --global-option="-L/usr/local/opt/openssl/lib"
Installing collected packages: MySQL-python, memsql
Running setup.py install for MySQL-python ... error
Complete output from command /System/Library/Frameworks/Python.framework/Versions/2.7/Resources/Python.app/Contents/MacOS/Python -u -c "import setuptools, tokenize;__file__='/private/tmp/pip-install-JDxMyP/MySQL-python/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" build_ext -I/usr/local/opt/openssl/include -L/usr/local/opt/openssl/lib install --record /private/tmp/pip-record-azfFw0/install-record.txt --single-version-externally-managed --compile:
running build_ext
building '_mysql' extension
creating build
creating build/temp.macosx-10.14-intel-2.7
cc -fno-strict-aliasing -fno-common -dynamic -g -Os -pipe -fno-common -fno-strict-aliasing -fwrapv -DENABLE_DTRACE -DMACOSX -DNDEBUG -Wall -Wstrict-prototypes -Wshorten-64-to-32 -DNDEBUG -g -fwrapv -Os -Wall -Wstrict-prototypes -DENABLE_DTRACE -arch i386 -arch x86_64 -pipe -Dversion_info=(1,2,5,'final',1) -D__version__=1.2.5 -I/usr/local/Cellar/mysql/8.0.15/include/mysql -I/usr/local/opt/openssl/include -I/System/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7 -c _mysql.c -o build/temp.macosx-10.14-intel-2.7/_mysql.o
_mysql.c:44:10: fatal error: 'my_config.h' file not found
#include "my_config.h"
^~~~~~~~~~~~~
1 error generated.
error: command 'cc' failed with exit status 1}
In order to install memsql-python you need to ensure that you have the dependencies already available. Specifically, the dependency that seems to be missing from your environment is libmysqlclient-dev or an equivalent package.
Note - you are overriding the include paths to point at your openssl installation which may be causing this issue due to how the compiler is searching for development headers.
According to the project's readme, use the following steps to get started quickly on Ubuntu:
sudo apt-get update
sudo apt-get install -y mysql-client python-dev libmysqlclient-dev python-pip
sudo pip install memsql
Use the following steps to get started with RHEL based distributions such as Amazon Linux or Centos:
sudo yum update
sudo yum install -y gcc mysql-devel
sudo pip install memsql
-- edit to address question regarding installation on Mac OSX
On a Mac it appears that you can install the mysql-client package from brew which in theory should provide the libmysqlclient-dev package. Once available try installing the memsql-python package without overriding linker flags since memsql-python should build fine without openssl. If you need openssl support then you will need to ensure that both the openssl and libmysqlclient-dev shared objects are available to the linker at compilation time.
This procedure worked for me:
brew remove mysql
brew install mysql#5.7
brew link --force mysql#5.7
I read a post and adjusted the procedure to link things in the /usr/local/bin instead of adding a new route to the PATH variable.
Reference: MacOS: "pip install MySQL-python" returning an error: "_mysql.c:44:10: fatal error: 'my_config.h' file not found"

Compile R with Intel MKL on Ubuntu 16.04

I installed Intel MKL library by running this:
# keys taken from https://software.intel.com/en-us/articles/installing-intel-free-libs-and-python-apt-repo
wget https://apt.repos.intel.com/intel-gpg-keys/GPG-PUB-KEY-INTEL-SW-PRODUCTS-2019.PUB
apt-key add GPG-PUB-KEY-INTEL-SW-PRODUCTS-2019.PUB
sudo sh -c 'echo deb https://apt.repos.intel.com/mkl all main > /etc/apt/sources.list.d/intel-mkl.list'
sudo apt-get update && sudo apt-get install intel-mkl-64bit
I added this to ~/.bashrc:
source /opt/intel/bin/compilervars.sh intel64
source /opt/intel/mkl/bin/mklvars.sh intel64
If I try to compile R with Intel MKL it doesn't work:
cd R-3.4.2
source /opt/intel/mkl/bin/mklvars.sh intel64
MKL="-Wl,--no-as-needed -lmkl_gf_lp64 -Wl,--start-group -lmkl_gnu_thread -lmkl_core -Wl,--end-group -fopenmp -ldl -lpthread -lm"
./configure --prefix=/opt/R/R-3.4.2-intel-mkl --enable-R-shlib --with-blas="$MKL" --with-lapack
make && sudo make install
Error message:
/home/pacha/R-3.4.2/bin/exec/R: error while loading shared libraries: libmkl_gf_lp64.so: cannot open shared object file: No such file or directory
But it works compiling with OpenBLAS:
cd R-3.4.2
./configure --prefix=/opt/R/R-3.4.2-openblas --enable-R-shlib --with-blas --with-lapack
make && sudo make install
It works with Ubuntu 17.04+ but not with 16.04 just like this other question using mkl, error while loading shared libraries: libmkl_intel_lp64.so

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"

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

Where can I find the real arm-none-linux-gnueabi?

Some time before I installed arm-none-linux-gnueabi-gcc compiler collection and compiled embedded applications for IGEP board. I have many Eclipse projects which has double build configurations (one for UBUNTU based desktop, the other for ARM based IGEPv2 board).
Now, I formatted my drive (I use Ubuntu 12.04) , I rescued my projects and what I see? "arm-none-linux-gnueabi-gcc" is not available? I can download it nowhere.. Instead, all the links go to another download by "Mentor Graphics", which is named "arm-none-eabi-gcc". I do not know the difference between. I setup this package and correct all my .../CodeSourcery/... type of paths to /MentorGraphics/..., but when I compile I have the following error:
/home/fercis/MentorGraphics/Sourcery_CodeBench_Lite_for_ARM_EABI/arm-none-eabi/include/termios.h:4:25:
fatal error: sys/termios.h: No such file or directory
Then I looked at the include file of the arm compiler collection under "/home/fercis/MentorGraphics/Sourcery_CodeBench_Lite_for_ARM_EABI/arm-none-eabi/include" and what I see was a termios.h under the .../include directory, which only includes .../include/sys/termios.h
#ifdef __cplusplus
extern "C" {
#endif
#include <sys/termios.h>
#ifdef __cplusplus
}
#endif
And, There is no "/sys/termios.h". Something must be terribly wrong! Help please?
You can build your own toolchain for the IGEPv2 following these steps:
Install dependencies:
$ sudo apt-get install diffstat
$ sudo apt-get install texi2html
$ sudo apt-get install texinfo
$ sudo apt-get install gawk
$ sudo apt-get install chrpath
$ sudo apt-get install gnupg
$ sudo apt-get install libcurl3
$ sudo apt-get install libcurl3-gnutls
$ sudo apt-get install python-pycurl
Clone IGEPv2 repo:
$ git clone -b denzil git://git.isee.biz/pub/scm/poky.git
Download isee layer:
$ cd poky
$ git clone -b denzil git://git.isee.biz/pub/scm/meta-isee.git
Setup bitbake environment:
$ source oe-init-build-env
Add isee layer on conf/bblayers.conf file:
BBLAYERS ?= " \
/path/to/poky/meta \
/path/to/poky/meta-yocto \
/path/to/poky/meta-isee \
"
Change MACHINE on conf/local.conf file:
MACHINE ??= "igep00x0"
This command generates toolchain:
$ bitbake meta-toolchain-sdk
This is a good time to take a long coffee...
At the end of process, SDK will be available here:
build/tmp/deploy/sdk/igep-sdk-yocto-toolchain-1.2.1-2.tar.bz2
Install SDK in your host machine:
$ tar xvfz igep-sdk-yocto-toolchain-1.2.1-2.tar.bz2 -C /
Enjoy it! :)