...
Boost
The build process for Boost uses its own build tool. The AP Bridge only uses a small set of the Boost libraries. Compiling only the necessary libraries is much faster than compiling the full Boost suite.
No Format |
---|
$ cd ~/dev/boost_1_60_0 $ ./bootstrap.sh --with-libraries=atomic,chrono,filesystem,program_options,system,thread,timer |
tools/build/src/user-config.jam
(relative to the Boost sources) with the following content:No Format |
---|
using gcc : arm : arm-linux-gnueabihf-g++ ; # or specify the PATH to the cross-compiler to be used |
The example assumes that the arm compiler is in your PATH. Otherwise you will need to specify the full path. Note that user-config.jam
can also be in $HOME.
Build with:
No Format |
---|
# from ~/dev/boost_1_60_0 $ ./b2 toolset=gcc-arm |
If successful, you will get a message informing you that the header files are in the boost source folder, and that the libraries are in the boost source folder under ./stage/lib
. You will need to copy the libraries to the appropriate location on your target (/opt/dust-apc/lib
).
Protocol Buffers
In addition to the runtime library and headers, the Protocol Buffers build also contains the protoc
compiler, which is used in the AP Bridge build process. There are two stages: the protoc
compiler must be built for the build host, and the libraries must be built for the target (if the target architecture is different from the build host). In order to avoid polluting the protobuf source directory, we use a sub-directory to build the different platforms.
The following steps first configures and builds protobuf for the build host and installs the protoc
compiler in /usr/local/bin
.
No Format |
---|
$ cd ~/dev/protobuf-2.5.0 $ mkdir i686-linux $ cd i686-linux $ ../configure $ make $ sudo make install $ sudo ldconfig |
Then, cross-compile the protobuf libraries for the target. To build the libraries so they can be installed in /opt/dust-apc
, use the --prefix
option in the configure step - this applies to both regular and cross-compilation. We also need to specify the location of the cross-compiler with the --host
option, and specify the location of the protoc compiler we just built with --with-protoc
option. We use DESTDIR=$HOME/dev
to install the libraries that the AP Bridge will be built against within the user's home directory.
No Format |
---|
#$ fromcd ~/dev/protobuf-2.5.0/i686-linux $ cd .. $ mkdir arm-linux $ cd arm-linux $ ../configure --host=arm-linux-gnueabihf --prefix=/opt/dust-apc --with-protoc=/usr/local/bin/protoc $ make $ make install DESTDIR=$HOME/dev |
ZeroMQ
The ZeroMQ library and headers can be built for the target with the standard build process.
No Format |
---|
$ cd ~/dev/zeromq-3.2.5 $ ./configure --host=arm-linux-gnueabihf --prefix=/opt/dust-apc $ make $ make install DESTDIR=$HOME/dev |
The czmq library and headers depend on the ZeroMQ library. The The czmq distribution requires an additional step of running autogen.sh to generate the configure script. We also need to specify build requires a pointer to where the ZeroMQ library is with the --with-libzmq
option.
No Format |
---|
$ cd ~/dev/czmq-1.3.2
$ ./autogen.sh
$ LIBS=-lstdc++ ./configure --host=arm-linux-gnueabihf --prefix=/opt/dust-apc --with-libzmq=$HOME/dev/opt/dust-apc
$ make
$ make install DESTDIR=$HOME/dev |
The AP Bridge software also uses an MIT licensed C++ wrapper for the ZeroMQ APIs, zmq.hpp. This header is included in the patches directory with the AP Bridge software. It must be copied alongside the installed ZeroMQ headers.
No Format |
---|
$ cp ~/dev/apbridge/patches/zmq.hpp ~/dev/opt/dust-apc/include/ |
Note |
---|
The ZeroMQ versions are out of date compared with the latest releases from the ZeroMQ project. The AP Bridge does not have an explicit dependency on the older version, but there may be API changes that have not been integrated into the AP Bridge software. |
log4cxx
The log4cxx library is used for logging informational and diagnostic messages to a file. The log4cxx requires the apr and apr-util libraries to be able to build from source. Each of these libraries can be built with the standard build process.
When building apr, the ./configure
step may fail if the script tries to perform a test that requires running a test program on the target. These tests can be bypassed by setting the configure variable(s) explicitlythe configure variable(s) explicitly.
Note | ||
---|---|---|
When building the apr and apr-util packages, some toolchains do not properly include the required pthread library dependency, leading to build errors in log4cxx. A workaround is to define the LIBS environment variable to include the required library.
|
No Format |
---|
$ export LIBS=-lpthread
$ cd ~/dev/apr-1.4.6
$ ./configure --host=arm-linux-gnueabihf --prefix=/opt/dust-apc ac_cv_file__dev_zero=yes ac_cv_func_setpgrp_void=yes apr_cv_tcp_nodelay_with_cork=yes apr_cv_process_shared_works=yes ac_cv_sizeof_struct_iovec=8 apc_cv_mutex_robust_shared=no apr_cv_mutex_recursive=yes
$ make
$ make install DESTDIR=$HOME/dev |
We need to tell apr-util configure
where to find apr with the --with-ap
r option.
No Format |
---|
$ cd ../apr-util-1.5.1 $ ./configure --host=arm-linux-gnueabihf --prefix=/opt/dust-apc --with-apr=../apr-1.4.6 $ make $ make install DESTDIR=$HOME/dev |
configure
where to find apr and apr-util.No Format |
---|
$ cd ~/dev/apache-log4cxx-0.10.0
$ patch -p1 < ~/dev/apbridge/patches/apache-log4cxx-0.10.0.patch
$ ./configure --host=arm-linux-gnueabihf --prefix=/opt/dust-apc --with-apr=../apr-1.4.6 --with-apr-util=../apr-util-1.5.1
$ make
$ make install DESTDIR=$HOME/dev |
Note |
---|
More recent releases of APR, such as 1.5.2, build a program to generate a header file. This step fails when cross-compiling. One workaround for this is to build APR for the build host and copy aside the generated file, then build the APR library for the target, copy the generated file into place when the make step fails and rerun make. |
GPSd
The AP Bridge software links against the gpsd library to retrieve status from a connected GPS. The AP Bridge connects to the Linux gpsd daemon using the libgps API. The build host requires the gps library and headers to be present when building the AP Bridge. Install gpsd (version 3.11 is used in the pre-packaged Raspbian image) and the development files on the target (see Raspberry Pi example below).
No Format |
---|
pi@raspberry$ sudo apt-get install gpsd libgps-dev |
Copy the library and headers to the build host, e.g. using scp.
No Format |
---|
$ scp pi@x.x.x.x:/PATH/libgps.so* $HOME/dev/opt/dust-apc/lib/ $ scp pi@x.x.x.x:/PATH/libgpsmm.h $HOME/dev/opt/dust-apc/include/ |
Note |
---|
In the example above, we use the distribution's GPSd package to leverage the package's configuration of the gpsd daemon and to take advantage of any GPSd improvements. This approach could fail if the gpsd API changes, or if the cross-compiler installed on the build host uses a different version of the runtime C libraries than the compiler used by the target's distribution packages. The symptoms of this failure are compilation errors related the gpsd API, or unresolved symbols in the libgps library when building the AP Bridge. Another approach is to build the GPSd daemon from source (using version 3.11 for compatibility) on the build host and to copy the headers and libraries to the appropriate directories. Then, install the gpsd daemon and libraries on the target. In this case, the gpsd daemon must be configured to run as a service on the target and connect to the GPS device if one is present. |
...