I've been struggling to cross-compile OpenCV for arm on my x64 dual Xeon running Ubuntu 16.04
I understand how cross-compiler work, and it's fine compiling a simple project, but OpenCV has lots of dependencies.
I do not understand how to load these dependencies (headers only?) on the host used to cross-compile
I have tried
dpkg --add-architecture armhf
and I have tried adding the urls in the sources.list to install the dependencies.
I have tried installing dependencies with the :armhf suffix but these dependencies tend to have dependencies themselves and I end up with error of the form: cannot install
I tried also to use
apt-get build-dep --download-only <dependency>:armhf
but that just didn't seem to help.
So, first I'd like to understand:
Do I need the dependent libraries with the source code, or just the headers? I would think I just need the headers, but I'm confused now.
What exactly do I need to do to get the dependencies on the host, in order to cross compile?
Sorry if it's vague; I'm just not sure where to look for this. Every tutorial I see on cross-compiling leaves dependencies aside, and the OpenCV project explanation on cross-compiling assumes the reader already knows all this...
Thanks for help
EDIT
I added my solution below, but I don't find this ideal since it requires to install everything on the target first.
Obviously, the dependencies are needed on the target anyways, but there is no need for all the dev libraries and headers for runtime
So I'm still looking for a better solution
I managed to cross-compile, but it was a little painful.
The only way I found so far to get the dependencies on the compiling host, was to simply copy the files from the target where I installed them.
The folders needed are mostly
/usr (especially usr/include, /usr/lib and /usr/bin)
/lib
/opt (if you had any special library setup there)
You can tar those folders and copy them over to the host, or use rsync.
After that, you have to make sure to configure the path with cmake.
I copied stuff to a folder called sysroot-chip at the same level as opencv and my build dir is also at the same level (outside of opencv)
and added the following flags to cmake:
-D INCLUDE_DIRECTORIES=../sysroot-chip/usr/lib \
-D INCLUDE_DIRECTORIES=../sysroot-chip/usr/bin \
-D INCLUDE_DIRECTORIES=../sysroot-chip/opt/lib \
-D INCLUDE_DIRECTORIES=../sysroot-chip/lib \
-D PYTHON2_INCLUDE_PATH=../sysroot-chip/usr/include/python2.7 \
-D PYTHON2_LIBRARIES=../sysroot-chip/usr/lib/python2.7 \
-D PYTHON2_NUMPY_INCLUDE_DIRS=../sysroot-chip/usr/lib/python2.7/dist-packages \
-D PYTHON3_INCLUDE_PATH=../sysroot-chip/usr/include/python3.4 \
-D PYTHON3_LIBRARIES=../sysroot-chip/usr/lib/python3.4 \
-D PYTHON3_NUMPY_INCLUDE_DIRS=../sysroot-chip//usr/lib/python3.4/dist-packages \
along with the cross compiling toolchain flag:
-D CMAKE_TOOLCHAIN_FILE=../opencv-3.1.0/platforms/linux/arm-gnueabi.toolchain.cmaketoolchain.cmake \
Related
I'm trying to cross-compile the yuma123 open source package on a Ubuntu 18.04 development system to a MIPS target, where yuma123 uses Autotools and shared libraries.
I am using a directory INSTALL_PREFIX=/tmp/yuma123 as a staging area for files to be copied to the MIPS target.
The code (cross-)compiles and links without any errors using:
autoreconf -i -f
./configure ...
make
However, how do I install to $INSTALL_PREFIX?
Should I specify some --prefix= options to ./configure as follows:
./configure \
--target=mipsel-buildroot-linux-gnu \
--host=mipsel-buildroot-linux-gnu \
--build=x86_64-unknown-linux-gnu \
--prefix=$INSTALL_PREFIX/usr \
--sysconfdir=$INSTALL_PREFIX/etc \
--localstatedir=$LOCALSTATEDIR \
--program-prefix=""
or should I specify DESTDIR= when I sudo make install as follows:
sudo make DESTDIR=$INSTALL_PREFIX install
What do I need to set above to ensure that libtool handles the $INSTALL_PREFIX directory correctly for shared libraries when cross-compiling in this way?
However, how do I install to $INSTALL_PREFIX?
Should I specify some --prefix= options to ./configure
[...]
or should I specify DESTDIR= when I sudo make install[?]
You should use DESTDIR for your use case, although in practice, it's possible that you could get away with using --prefix.
The --prefix option conveys the prefix of the intended permanent installation location to the Autotools. Under some circumstances, this path or paths derived from it may end up being incorporated into the built binaries (RPATHs, config-file locations, etc.) or into built documentation. This is especially true if you're using libtool. That's obviously undesirable if the prefix is not reflective of where you intend the files actually to live on the target system.
DESTDIR, on the other hand, is for exactly the purpose you describe: installing into a into a staging area or an alternative root. This is what package builders generally use, for example, though I suspect that the alternative root angle was the one that originally inspired the facility. Note, too, that if you're installing to a staging area then you probably don't need to use sudo to make install.
This is the first time for me to use Linux and its development tools. When I was trying to build the project I have to read, I had an error:
/home/charlie/AODV/llf.c:36: error: iwlib.h: No such file or directory
I was building the project with Qt. Beforehand, I installed libnl by make and make install, but the problem was not resolved. I am wondering if I did not install libel correctly or there are something more I have to do.
Welcome to Linux development.
You need to install libiw and it's development header(s).
How to do this is distribution dependant. On my Debian (should be more or less the same on any Debian based distro like Ubuntu):
jbm#sumo:~$ apt-cache search libiw
libiw-dev - Wireless tools - development files
libiw30 - Wireless tools - library
libiw30 is the binary lib, and the *-dev package is for it's header file(s), plus sometimes some docs (man pages etc). So:
jbm#sumo:~$ sudo apt-get install libiw-dev
Reading package lists... Done
Building dependency tree
Reading state information... Done
[...]
The following additional packages will be installed:
libiw30
The following NEW packages will be installed:
libiw-dev libiw30
Note how installing the header(s) for a lib rightfully install the library as well.
After install:
jbm#sumo:~$ find /usr/include/ -name iwlib.h
/usr/include/iwlib.h
jbm#sumo:~$ find /usr/lib -name "libiw*"
/usr/lib/x86_64-linux-gnu/libiw.so
/usr/lib/x86_64-linux-gnu/libiw.a
Note that:
/usr/include is part of the standard search path for headers of your
gcc toolchain, so you don't need to add a peculiar -I (for "include")
option.
/usr/lib is the same for lib binaries, so no need any -l or
-L (for "link") option.
You need to say to the compiler where to look for the header file. Use the -Idir option with dir the directory where the header file is.
I'm rather new to programming and I need help with libraries. I'm having trouble understanding how to use the libraries. I simply don't know what to do after I download them. They usually have instructions but they're not easy to follow when you're a beginner I suppose.
After they're downloaded I'm faced with a bunch of stuff. Some people say I need to build them but I don't know how to do that. Also there's some "header only libraries" and I don't know what to do with those as well.
Example of what I mean, Boost & portaudio (or any other library), I don't know where to start or what to do.
Can someone help me, please!
First, see if there’s a distribution for your OS. On Ubuntu, installing the package through the software manager will install all the files you need for boost in the system directory, /usr/include/. This is by far the simplest solution.
If this is not an option, you need to build the library from source and install it in a directory of your own choice. This will usually be your home directory or /usr/local. Typically, the commands for this will be something like:
tar xzvf library-x.y.z.tgz
cd library-x.y.z
less README
./configure --help
./configure --prefix=/usr/local --other=options --as=appropriate
make
sudo -u bin -g bin make install
make clean
You might then need to add -I/usr/local/include and -L/usr/local/lib to your compiler command line.
For some libraries, you might need to look up the directories to include with a tool such as pkg-config. If you need to do this, the commands would be:
export CFLAGS=$CFLAGS `pkg-config --cflags library`
export LDFLAGS=$LDFLAGS `pkg-config --libs library`
Can someone explain what is a correct way to include some modules and addons while doing ./configure in Qt5.5.1?
I should have a x11 addon installed and tried that with:
./configure -qt-x11
./configure -qt-x11extrass
but it doesn't work.
I am reading this for configure options, but I figured out that many things you have to guess how they need to be done. I am building qt5.5.1 on Ubuntu 14.04.3 to cross-compile for BBB.
If you want to build some module (all module dependency packages must be installed first), you need to go to module directory (for example qtmultimedia in qt directory) and run qmake (built for your specific architecture), after that make and sudo make install. Now you will be able to include required module into your .pro file.
I'm trying to install boost into include directory for avoid -I flag use in each g++ compiler call,I installed using this command line: ./bjam --prefix=/usr/include install
see --prefix value, it install in /home/myusername, why?
Thanks in advance.
You would need root permissions to install in /usr/include.
Actually your system has done you a favor by not letting you do that. The --prefix option says where to install everything -- headers, libraries, executables, documentation, etc. For example, the header files would be installed in /usr/include/include, which is not going to be in your compiler's search path.
Disclaimer:: This assume that ./bjam --prefix=... behaves similarly to ./configure --prefix=.... I haven't actually used bjam. If bjam's --prefix option means something else, please correct me.
Depending on your system, you may be able to install Boost from a repository rather than building it from source. For Debian or Ubuntu, for example, something like sudo apt-get install libboost might work.
Note that I said something like that; it appears that Boost consists of a number of packages; apt-cache search boost, or better yet, do a Google search to see how to install Boost on your particular system.
Try running
sudo ./bjam
Doing this should run bjam with appropriate privileges to install to /usr/local/include and /usr/local/lib, both of which should be in your search path...