I want to cross-compile D-bus to arm.
Toolchain: arm-linux-gcc-3.4.1
configure option: CC=arm-linux-gcc ./configure --prefix=/opt/db开发者_高级运维us/ --host=arm-linux --enable-abstract-sockets -with-xml=expat
Source code: d-bus-1.2.24 d-bus-1.3.1 d-bus-1.4.0
make[2]: Entering directory `/home/mandy/Desktop/apps/d-bus/remotec/dbus-1.4.0/bus'
CCLD dbus-daemon
/usr/local/arm/3.4.1/lib/gcc/arm-linux/3.4.1/../../../../arm-linux/bin/ld: Warning: gc-sections option ignored
dbus_daemon-bus.o(.text.process_config_postinit+0x120): In function `bus_context_check_security_policy':
/home/mandy/Desktop/apps/d-bus/remotec/dbus-1.4.0/bus/bus.c:1638: undefined reference to `bus_set_watched_dirs'
/usr/local/arm/3.4.1/lib/gcc/arm-linux/3.4.1/../../../../arm-linux/lib/libc_nonshared.a(elf-init.oS)(.text+0x44): In function `__libc_csu_init':
: undefined reference to `__init_array_end'
/usr/local/arm/3.4.1/lib/gcc/arm-linux/3.4.1/../../../../arm-linux/lib/libc_nonshared.a(elf-init.oS)(.text+0x48): In function `__libc_csu_init':
: undefined reference to `__init_array_start'
/usr/local/arm/3.4.1/lib/gcc/arm-linux/3.4.1/../../../../arm-linux/lib/libc_nonshared.a(elf-init.oS)(.text+0x8c): In function `__libc_csu_fini':
: undefined reference to `__fini_array_end'
/usr/local/arm/3.4.1/lib/gcc/arm-linux/3.4.1/../../../../arm-linux/lib/libc_nonshared.a(elf-init.oS)(.text+0x90): In function `__libc_csu_fini':
: undefined reference to `__fini_array_start'
collect2: ld returned 1 exit status
make[2]: *** [dbus-daemon] Error 1
make[2]: Leaving directory `/home/mandy/Desktop/apps/d-bus/remotec/dbus-1.4.0/bus'
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory `/home/mandy/Desktop/apps/d-bus/remotec/dbus-1.4.0'
make: *** [all] Error 2
at dbus-1.2.24 and dbus-1.3.1 also get the same error.
What can I do to fix the error?
These are the general instructions to cross compile dbus for the avr32 architecture. Based on this reference(3rd post) for the arm I create this little tutorial. I am posting my tutorial because it could be useful for others or even for you to compare the commands.
Expat libraries
To cross-compile D-Bus, first cross-compile the expat library. Use prefix
to specify its install path.
Download the expat src code: ftp://ftp.free.fr/.mirrors1/ftp.netbsd.org/packages/distfiles/expat-2.0.1.tar.gz
Untar it:
tar zxvf expat-2.0.1.tar.gz
Configure it with the appropriate host and c compiler. You must have the avr32 Linux tool-chain installed (Buildroot compile the tool-chain for you, you must add the binaries path to the environment variable $PATH)
cd expat-2.0.1/
./configure --host=avr32-linux --prefix=/home/juan/builds/build_expat/ CC=avr32-linux-gcc
make; make install
D-Bus
Download the D-Bus src code: http://dbus.freedesktop.org/releases/dbus/dbus-1.5.0.tar.gz
Untar it:
tar zxvf dbus-1.5.0.tar.gz
cd dbus-1.5.0.tar.gz
Configure specifying the installation folder (--prefix
), the C compiler, the include folder and the lib folder for expat libraries:
./configure --prefix=/home/juan/builds/build_dbus/ --host=avr32-linux --with-x=no ac_cv_have_abstract_sockets=yes "CC=avr32-linux-gcc -I/home/juan/builds/build_expat/include -L/home/juan/builds/build_expat/lib"
make;make install;
Debian Linux
The following steps cross-compile D-Bus on Debian Linux to Windows, which may be useful for cross-compiling to other platforms by changing the the compiler from i686-w64-ming32 to the compiler required for your purposes:
sudo apt-get -y install mingw-w64 cmake autoconf-archive
mkdir $HOME/dbus
cd $HOME/dbus
git clone https://github.com/libexpat/libexpat.git
cd libexpat/expat
./buildconf.sh
./configure --host=i686-w64-mingw32
make
make install DESTDIR=$HOME/dbus/expat
cd $HOME/dbus
git clone https://gitlab.freedesktop.org/dbus/dbus.git dbus-src-root
mkdir dbus-build
cd dbus-build
cmake -DCMAKE_TOOLCHAIN_FILE=../dbus-src-root/cmake/i686-w64-mingw32.cmake \
-DCMAKE_FIND_ROOT_PATH=/usr/i686-w64-mingw32/sysroot/i686-w64-mingw32 \
-DEXPAT_LIBRARY=$HOME/dbus/expat/usr/local/lib/libexpat.a \
-DEXPAT_INCLUDE_DIR=$HOME/dbus/expat/usr/local/include \
-DDBUS_ENABLE_XML_DOCS:BOOL=OFF -DDBUS_BUILD_TESTS:BOOL=OFF ../dbus-src-root
make
make install DESTDIR=$HOME/dbus/dbus
The D-Bus daemon is at $HOME/dbus/dbus/usr/local/bin/dbus-daemon.exe
.
精彩评论