cross-compile yuma123 using autotools for a MIPS target - build

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.

Related

How to build boost with correct paths

I tried to build boost in a separate path on my Ubuntu 18 Linux system. I cloned the GIT repository since I want to have the latest version available (the package repositories provide an old version only). The library I want to use is boost::timer.
This is what I did:
git clone --recursive https://github.com/boostorg/boost.git
cd boost
./bootstrap.sh
./b2 headers
./b2
This kind of worked. However I expected the static library to be located in a different path. It was compiled into this path:
.../boost/bin.v2/libs/timer/build/gcc-9/release/link-static/threading-multi/visibility-hidden/libboost_timer.a
This path is very verbos and it contains the compiler and its version which means I would need to update the paths when updating GCC or changing the compiler.
I would have expected it here:
.../boost/libs/timer/libboost_timer.a
Did I do something wrong? Is the placement expected that way?
Ok, when reading the build output carefully even a fool like me could notice that the actual path is boost/stage/lib. All built libs can be found there.

How to compile qtwebkit in qt-5.8

I have compiled QT-5.8 from github successfully, each submodule is cloned by init-repository provided by QT. However, in Qt5.8, it has removed qtwebkit.
But my app needs qtwebkit, so I clone qtwebkit submodule and qmake it.
However, it shows the compilation errors
( test -e Makefile.api || /usr/local/Qt-5.8.0/bin/qmake -o Makefile.api /home/tumh/qt5/qtwebkit/Source/api.pri ) && make -f Makefile.api
make[1]: Entering directory '/home/tumh/qt5/qtwebkit/Source'
make[1]: *** No rule to make target '/home/tumh/qt5/qtwebkit/Source/WebCore//libWebCore.a', needed by '../lib/libQt5WebKit.so.5.8.0'. Stop.
make[1]: Leaving directory '/home/tumh/qt5/qtwebkit/Source'
Makefile:40: recipe for target 'sub-api-pri-make_first-ordered' failed
make: *** [sub-api-pri-make_first-ordered] Error 2
I have no idea that how to compile a single submodule in QT.
Any suggestion is appreciated.
thanks!
You should take tarball of webkit from official releases. It should build fine with Qt-5.8.
The following describes how to compile qtwebkit module so it is usable with Qt 5.9.9. I assume the process is similar if not identical for Qt 5.8.
An overview of the process
All of the required components should be compiled using one tool chain. I suggest using the one installed with Qt.
You gonna need ICU compiled, the source code can be obtained from the official site.
The source code of qtwebkit module that we want to compile is available here (thx #J. Doe for the link!)
Regardless of the operating system you are working on, in order to compile qtwebkit module you gonna need the following additional tools:
ruby
gperf
flex
bison
python 2
Qtwebkit module depends on declarative module. It becomes available when qtquick1 is installed.
It is assumed that Qt 5.9.9 is installed. I was using these installers.
The process takes some time so if you need the module ready ASAP go to the last section (What if you cannot perform some of the above steps).
Compiling on Windows (tested on Win10)
On Windows I recommend using chocolatey to install additional tools.
Compiling ICU
Install msys2 package via chocolatey. It allows to use the scrips provided with ICU source code with very few modifications.
Installation script requires make program available. It doesn't matter if mingw32-make is virtually (of even literally) the same tool. Copy mingw32-make.exe and rename it to make.exe.
Using cmd with integrated mingw tools (installed along with Qt) open msys2 shell forwarding the PATH variable.
msys2_shell -use-full-path
Go to the ICU source code directory (mine was C:\icu\source) and run
./runConfigureICU MinGW -prefix=$PWD/../dist
(It is expected to encounter "unknown platform" issue, no worries)
Now run:
gcc -dumpmachine
Save the output, in my case it was i686-w64-mingw32.
Using this result execute:
./configure -build=i686-w64-mingw32 -prefix=$PWD/../dist
(modify build parameter according to the result of the previous step)
Now, you should be able to compile ICU with:
make & make install
(If you want to speed things up you can engage multiple CPU cores in the above process. For example in order to engage 777 cores execute make -j777 & make install)
Assuming your ICU source code was in C:\icu\source directory, the result of the compilation should be in C:\icu\dist.
Compiling qtwebkit module
As said in the first section, compiling qtwebkit module requires additional tools.
They can be installed via chocolatey using the following command:
choco install ruby gperf winflexbison python2
This, among others, installs win_flex.exe and win_bison.exe. As of this writing these executables are located (at least in my case) in C:\ProgramData\chocolatey\lib\winflexbison\tools .
The qmake checks for programs named bison.exe and flex.exe. So I have copied both win_flex.exe and win_bison.exe and renamed them flex.exe and bison.exe accordingly.
The last step is to add both of these programs to PATH variable.
To do so execute (in cmd with integrated mingw tools) the following command:
set PATH=C:\ProgramData\chocolatey\lib\winflexbison\tools;%PATH%
Additionally you need to point to the directory where includes and libs of compiled ICU are located. I have done it like this:
set PATH=C:\icu\dist\bin;%PATH%
set INCLUDE=C:\icu\dist\include;
set LIB=C:\icu\dist\lib;
Above assumes that prior to executing this commands there was no variables named INCLUDE and LIB set in the currently used cmd.
Finally, qmake process checks for a variable named SQLITE3SRCDIR.
As suggested by this answer you can set it to sqlite sources provided with Qt. In my case it was done like this:
set SQLITE3SRCDIR=C:\Qt\Qt5.9.9\5.9.9\Src\qtbase\src\3rdparty\sqlite
Now (using the same cmd) go to the directory where Qt sources are located and execute configure.bat. I have done both of these steps with:
cd C:\Qt\Qt5.9.9\5.9.9\Src
configure.bat
Finally, extract the downloaded source code of the qtwebkitmodule to the sources directory of Qt (C:\Qt\Qt5.9.9\5.9.9\Src in my case) and make a module. I have done it like this:
cd qtwebkit-opensource-src-5.9.0
mkdir build
cd build
qmake -r ..
make
make install
It is strongly recommended to utilize multiple cores in the make process, otherwise prepare yourself for a very long compilation.
Now you should be able to use webkit and webkitwidgets in your Qt projects.
Compiling on Linux (tested on LUbuntu 18.04)
I suggest using compilation tools provided with Qt instead of default make and g++ compiler. To do so I have exported path to the tools provided with Qt like this:
export PATH=/home/$USER/Qt5.9.9/5.9.9/gcc_64/bin/:$PATH
You gonna need ICU compiled. I suggest using version 56.1 as it is the same shipped with Qt 5.9.9. The compilation process is almost identical as it was described for Windows. the only difference is that you run:
./runConfigureICU Linux/gcc --prefix=$PWD/../dist
and later configure script can be omitted on Linux.
On lUbuntu 18.04 I needed the following packages installed:
apt-get install ruby bison gperf python flex perl libx11-dev xserver-xorg-dev xorg-dev libpulse-dev libsqlite3-dev
As with compiling qtwebkit on Windows, you gonna need qtquick1 module installed.
I have encountered an error saying that some headers related to OpenGL were missing. If you have the same problem then in my case installing libgl1-mesa-dev package solved it.
Now extract source code of qtwebkit module sources directory of your Qt installation. In my case it was "/home/$USER/Qt5.9.9/5.9.9/Src".
Modify WTF.pri file and add the path to ICU includes and libs after the first INCLUDEPATH. In my case it was done like this:
...
INCLUDEPATH += /home/$USER/icu/dist/include/
LIBS += -L/home/$USER/icu/dist/lib/
...
Note '-L' is placed before path pointing to libs.
Now you should be able to compile qtwebkit module in usual manner:
mkdir build
cd build
qmake -r ..
make & make install
What if you cannot perform some of the above steps
You can always try to use prebuild binaries:
https://download.qt.io/snapshots/ci/qtwebkit/5.9/latest/qtwebkit/
or unofficial fork of the qtwebkit module:
https://github.com/qtwebkit/qtwebkit/releases

cross-compile with dependencies: how to get target dependencies on host?

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 \

why can't I to install boost in /usr/include?

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...

How can I build libpoppler from source?

I just download poppler to Linux system,and I want to incorporate it in my app to parse pdf file.
(My goal is to convert pdf file to plain text.)
How can I do this?
Poppler's git tree includes a useless INSTALL doc that just tells you to run ./configure, but they don't include automake/autoconf auto-generated files (including configure) in git. (Probably they do include them in tarball source releases.)
I just built poppler from git source (on Ubuntu 15.04) like so:
git clone --depth 50 --no-single-branch git://git.freedesktop.org/git/poppler/poppler
cmake -G 'Unix Makefiles' # other -G options are to generate project files for various IDEs
# look at the output. If it didn't find some libraries,
# install them with your package manager and re-run cmake
make -j4
# optionally:
sudo make install
It appears that they maintain an autoconf/automake build setup, so you can use that OR cmake to create a Makefile.
If you just want to see if the latest git poppler works better than the distro package, you don't need to sudo make install, you can just run utils/pdftotext or whatever right from the source directory. It apparently tells the linker to embed the build path into the binary, as a library search path, so running /usr/local/src/poppler/utils/pdftotext works, and finds /usr/local/src/poppler/libpoppler.so.52.
If the latest poppler does work better than the distro-packaged poppler, you should install it to /usr/local/bin with sudo make install. When you upgrade to the next version of your distro, check your /usr/local. Often the new distro version will be newer than when you built it from source, so you should just remove your version from /usr/local/{bin,share,lib,man,include}. (Or make uninstall in the source dir, if supported).
Their website explains it very clearly :
Poppler is available from git. To clone the repository use the following command:
git clone git://git.freedesktop.org/git/poppler/poppler
Once you download the source code, read the INSTALL file where it says :
cd to the directory containing the package's source code and type
./configure to configure the package for your system.
Type `make' to compile the package.
Type `make install' to install the programs and any data files and
documentation.
Since some time has passed and it seems there was some uncertainty, I also took a look.
At the end of 2021, their homepage says
We run continuous integration via the gitlab CI
I checked out their .gitlab-ci.yml which has many build tasks. It would seem these days we build libpoppler like this:
git clone git://git.freedesktop.org/git/poppler/test test.repo
mkdir -p build && cd build
cmake -DTESTDATADIR=`pwd`/../test.repo -G Ninja ..
ninja