第一次发帖~
我正在尝试将 ActiveMQ-cpp 客户端移植到 ARM 平台(Beaglebone/BeagleBoard) - 因为我在我的 PC 上进行开发,所以我需要交叉编译 ActiveMQ-cpp 库才能运行在 ARM 系统上。
我按照他们的构建指令中的步骤进行操作,除了我使用以下代码编译 APR 和 APR-util 库:
对于 4 月:
./configure --prefix=/usr/arm-linux-gnueabi/apr --host=arm-linux-gnueabi CC="arm-linux-gnueabi-gcc" CXX="arm-linux-gnueabi-g++" 我跑进行安装,一切都很好。
对于 APR 实用程序:
./configure --prefix=/usr/arm-linux-gnueabi/apr-util --host=arm-linux-gnueabi -with-apr=/usr/arm-linux-gnueabi/apr CC="arm-linux- gnueabi-gcc" CXX="arm-linux-gnueabi-g++" 我运行 make install 得到了这个:
/home/peter/apache/Apache_apr/apr-util-1.5.1/xml/expat/.libs/libexpat.so: could not read symbols: File in wrong format
经过一番搜索,我“认为”问题在于 libexpat 格式错误(为 i386 编译?)
我的问题是:如何为 ARM 平台正确编译 ActiveMQ-cpp 库?有什么方法可以修复 libexpat.so 吗?还是跳过 Apr-util?还是 ./configure 中的某个选项用于 Apr-util?
跟进:这是运行配置的日志文件:
checking build system type... i686-pc-linux-gnu
checking host system type... arm-unknown-linux-gnueabi
checking target system type... arm-unknown-linux-gnueabi
checking for a BSD-compatible install... /usr/bin/install -c
checking for working mkdir -p... yes
APR-util Version: 1.5.1
checking for chosen layout... apr-util
checking for arm-linux-gnueabi-gcc... arm-linux-gnueabi-gcc
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables...
checking whether we are cross compiling... yes
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether arm-linux-gnueabi-gcc accepts -g... yes
checking for arm-linux-gnueabi-gcc option to accept ISO C89... none needed
Applying apr-util hints file rules for arm-unknown-linux-gnueabi
checking for APR... yes
setting CPP to "gcc -E"
adding "-pthread" to CFLAGS
setting CPPFLAGS to " -D_REENTRANT -D_GNU_SOURCE -D_LARGEFILE64_SOURCE"
checking how to run the C preprocessor... gcc -E
checking for grep that handles long lines and -e... /bin/grep
checking for egrep... /bin/grep -E
checking for ANSI C header files... yes
checking for sys/types.h... yes
checking for sys/stat.h... yes
checking for stdlib.h... yes
checking for string.h... yes
checking for memory.h... yes
checking for strings.h... yes
checking for inttypes.h... yes
checking for stdint.h... yes
checking for unistd.h... yes
checking for ldap support...
checking for default DBM... sdbm (default)
checking for pg_config... no
checking libpq-fe.h usability... no
checking libpq-fe.h presence... no
checking for libpq-fe.h... no
checking postgresql/libpq-fe.h usability... no
checking postgresql/libpq-fe.h presence... no
checking for postgresql/libpq-fe.h... no
checking sqlite3.h usability... no
checking sqlite3.h presence... no
checking for sqlite3.h... no
checking sqlite.h usability... no
checking sqlite.h presence... no
checking for sqlite.h... no
checking sybdb.h usability... no
checking sybdb.h presence... no
checking for sybdb.h... no
checking freetds/sybdb.h usability... no
checking freetds/sybdb.h presence... no
checking for freetds/sybdb.h... no
checking for odbc_config... no
checking sql.h usability... no
checking sql.h presence... no
checking for sql.h... no
checking odbc/sql.h usability... no
checking odbc/sql.h presence... no
checking for odbc/sql.h... no
checking Expat 1.95.x... no
checking old Debian-packaged expat... no
checking old FreeBSD-packaged expat... no
checking Expat 1.0/1.1... no
setting LDFLAGS to "-L/usr/local/lib"
adding "-I/usr/local/include" to CPPFLAGS
checking Expat 1.95.x in /usr/local... no
nulling LDFLAGS
removed "-I/usr/local/include" from CPPFLAGS
configuring package in xml/expat now
checking build system type... i686-pc-linux-gnu
checking host system type... arm-unknown-linux-gnueabi
checking target system type... arm-unknown-linux-gnueabi
checking how to print strings... printf
checking for arm-linux-gnueabi-gcc... arm-linux-gnueabi-gcc
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables...
checking whether we are cross compiling... yes
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether arm-linux-gnueabi-gcc accepts -g... yes
checking for arm-linux-gnueabi-gcc option to accept ISO C89... none needed
checking for a sed that does not truncate output... /bin/sed
checking for grep that handles long lines and -e... /bin/grep
checking for egrep... /bin/grep -E
checking for fgrep... /bin/grep -F
checking for ld used by arm-linux-gnueabi-gcc... /usr/arm-linux-gnueabi/bin/ld
checking if the linker (/usr/arm-linux-gnueabi/bin/ld) is GNU ld... yes
checking for BSD- or MS-compatible name lister (nm)... /usr/bin/arm-linux-gnueabi-nm -B
checking the name lister (/usr/bin/arm-linux-gnueabi-nm -B) interface... BSD nm
checking whether ln -s works... yes
checking the maximum length of command line arguments... 1572864
checking whether the shell understands some XSI constructs... yes
checking whether the shell understands "+="... yes
checking how to convert i686-pc-linux-gnu file names to arm-unknown-linux-gnueabi format... func_convert_file_noop
checking how to convert i686-pc-linux-gnu file names to toolchain format... func_convert_file_noop
checking for /usr/arm-linux-gnueabi/bin/ld option to reload object files... -r
checking for arm-linux-gnueabi-objdump... objdump
checking how to recognize dependent libraries... pass_all
checking for arm-linux-gnueabi-dlltool... dlltool
checking how to associate runtime and link libraries... printf %s\n
checking for arm-linux-gnueabi-ar... arm-linux-gnueabi-ar
checking for archiver @FILE support... @
checking for arm-linux-gnueabi-strip... arm-linux-gnueabi-strip
checking for arm-linux-gnueabi-ranlib... arm-linux-gnueabi-ranlib
checking for gawk... no
checking for mawk... mawk
checking command to parse /usr/bin/arm-linux-gnueabi-nm -B output from arm-linux-gnueabi-gcc object... ok
checking for sysroot... no
checking for arm-linux-gnueabi-mt... no
checking for mt... mt
configure: WARNING: using cross tools not prefixed with host triplet
checking if mt is a manifest tool... no
checking how to run the C preprocessor... arm-linux-gnueabi-gcc -E
checking for ANSI C header files... yes
checking for sys/types.h... yes
checking for sys/stat.h... yes
checking for stdlib.h... yes
checking for string.h... yes
checking for memory.h... yes
checking for strings.h... yes
checking for inttypes.h... yes
checking for stdint.h... yes
checking for unistd.h... yes
checking for dlfcn.h... yes
checking for objdir... .libs
checking if arm-linux-gnueabi-gcc supports -fno-rtti -fno-exceptions... no
checking for arm-linux-gnueabi-gcc option to produce PIC... -fPIC -DPIC
checking if arm-linux-gnueabi-gcc PIC flag -fPIC -DPIC works... yes
checking if arm-linux-gnueabi-gcc static flag -static works... yes
checking if arm-linux-gnueabi-gcc supports -c -o file.o... yes
checking if arm-linux-gnueabi-gcc supports -c -o file.o... (cached) yes
checking whether the arm-linux-gnueabi-gcc linker (/usr/arm-linux-gnueabi/bin/ld) supports shared libraries... yes
checking whether -lc should be explicitly linked in... no
checking dynamic linker characteristics... GNU/Linux ld.so
checking how to hardcode library paths into programs... immediate
checking whether stripping libraries is possible... yes
checking if libtool supports shared libraries... yes
checking whether to build shared libraries... yes
checking whether to build static libraries... yes
checking for arm-linux-gnueabi-gcc... (cached) arm-linux-gnueabi-gcc
checking whether we are using the GNU C compiler... (cached) yes
checking whether arm-linux-gnueabi-gcc accepts -g... (cached) yes
checking for arm-linux-gnueabi-gcc option to accept ISO C89... (cached) none needed
checking for a BSD-compatible install... /usr/bin/install -c
checking for ANSI C header files... (cached) yes
checking for an ANSI C-conforming const... yes
checking for size_t... yes
checking for memmove... yes
checking for bcopy... yes
checking check.h usability... no
checking check.h presence... no
checking for check.h... no
configure: creating ./config.status
config.status: creating Makefile
config.status: creating expat_config.h
config.status: expat_config.h is unchanged
config.status: executing libtool commands
xml/expat configured properly
setting APRUTIL_INCLUDES to "-I/home/jacky/apache/Apache_apr/apr-util-1.5.1/xml/expat/lib"
setting LDFLAGS to "-L/home/jacky/apache/Apache_apr/apr-util-1.5.1/xml/expat/lib"
setting APRUTIL_EXPORT_LIBS to "/home/jacky/apache/Apache_apr/apr-util-1.5.1/xml/expat/libexpat.la"
setting APRUTIL_LIBS to "/home/jacky/apache/Apache_apr/apr-util-1.5.1/xml/expat/libexpat.la"
checking iconv.h usability... yes
checking iconv.h presence... yes
checking for iconv.h... yes
checking for type of inbuf parameter to iconv... char **
checking for iconv.h... (cached) yes
checking langinfo.h usability... yes
checking langinfo.h presence... yes
checking for langinfo.h... yes
checking for nl_langinfo... yes
checking for CODESET in langinfo.h... yes
checking whether APR has DSO support... yes
checking for library containing crypt... -lcrypt
checking if system crypt() function is threadsafe... no
checking for crypt_r... yes
checking style of crypt_r... struct_crypt_data
adding "/usr/arm-linux-gnueabi/apr/lib/libapr-1.la" to APRUTIL_LIBS
adding "-luuid" to APRUTIL_LIBS
adding "-lrt" to APRUTIL_LIBS
adding "-lcrypt" to APRUTIL_LIBS
adding "-lpthread" to APRUTIL_LIBS
adding "-ldl" to APRUTIL_LIBS
configure: creating ./config.status
config.status: creating Makefile
config.status: creating export_vars.sh
config.status: creating build/pkg/pkginfo
config.status: creating apr-util.pc
config.status: creating apu-1-config
config.status: creating include/private/apu_select_dbm.h
config.status: creating include/apr_ldap.h
config.status: creating include/apu.h
config.status: creating include/apu_want.h
config.status: creating test/Makefile
config.status: creating include/private/apu_config.h
config.status: executing default commands
据我所知,xml/expat 配置正确。我想 - 也许我需要在 gcc-arm-linux 中编译 expat 库?我继续这样做,然后再次运行配置:
./configure --prefix=/usr/arm-linux-gnueabi/apr-util --host=arm-linux-gnueabi -with-apr=/usr/arm-linux-gnueabi/apr -with-expat=/usr /arm-linux-gnueabi/expat CC="arm-linux-gnueabi-gcc" CXX="arm-linux-gnueabi-g++"
我在日志中得到了类似的结果,除了我现在有 Expat 1.95.x:
checking for odbc/sql.h... no
setting LDFLAGS to "-L/usr/arm-linux-gnueabi/expat/lib"
adding "-I/usr/arm-linux-gnueabi/expat/include" to CPPFLAGS
setting APRUTIL_INCLUDES to "-I/usr/arm-linux-gnueabi/expat/include"
setting APRUTIL_LDFLAGS to "-L/usr/arm-linux-gnueabi/expat/lib"
checking Expat 1.95.x... yes
setting APRUTIL_EXPORT_LIBS to "-lexpat"
setting APRUTIL_LIBS to "-lexpat"
运行make,出现同样的错误。
我搜索了与 libexpat.so 相关的错误。我注意到那些想要交叉编译的人通常会看到这个“libexpat.so”错误:使用centos 5.2 64bits,或者使用 Xeon 64bit 的其他情况。
以下是实际导致错误的命令:
make[1]: Entering directory `/home/jacky/apache/Apache_apr/apr-util-1.5.1'
/bin/bash /usr/arm-linux-gnueabi/apr/build-1/libtool --silent --mode=link gcc -g -O2 -pthread -DHAVE_CONFIG_H -D_REENTRANT -D_GNU_SOURCE -D_LARGEFILE64_SOURCE -I/home/jacky/apache/Apache_apr/apr-util-1.5.1/include -I/home/jacky/apache/Apache_apr/apr-util-1.5.1/include/private -I/usr/arm-linux-gnueabi/apr/include/apr-1 -I/usr/arm-linux-gnueabi/expat/include -version-info 5:1:5 -o libaprutil-1.la -rpath /usr/arm-linux-gnueabi/apr-util/lib buckets/apr_brigade.lo buckets/apr_buckets.lo buckets/apr_buckets_alloc.lo buckets/apr_buckets_eos.lo buckets/apr_buckets_file.lo buckets/apr_buckets_flush.lo buckets/apr_buckets_heap.lo buckets/apr_buckets_mmap.lo buckets/apr_buckets_pipe.lo buckets/apr_buckets_pool.lo buckets/apr_buckets_refcount.lo buckets/apr_buckets_simple.lo buckets/apr_buckets_socket.lo crypto/apr_crypto.lo crypto/apr_md4.lo crypto/apr_md5.lo crypto/apr_passwd.lo crypto/apr_sha1.lo crypto/crypt_blowfish.lo crypto/getuuid.lo crypto/uuid.lo dbd/apr_dbd.lo dbm/apr_dbm.lo dbm/apr_dbm_sdbm.lo dbm/sdbm/sdbm.lo dbm/sdbm/sdbm_hash.lo dbm/sdbm/sdbm_lock.lo dbm/sdbm/sdbm_pair.lo encoding/apr_base64.lo hooks/apr_hooks.lo ldap/apr_ldap_stub.lo ldap/apr_ldap_url.lo memcache/apr_memcache.lo misc/apr_date.lo misc/apr_queue.lo misc/apr_reslist.lo misc/apr_rmm.lo misc/apr_thread_pool.lo misc/apu_dso.lo misc/apu_version.lo strmatch/apr_strmatch.lo uri/apr_uri.lo xlate/xlate.lo xml/apr_xml.lo -luuid -lrt -lcrypt -lpthread -ldl -L/usr/arm-linux-gnueabi/expat/lib -lexpat /usr/arm-linux-gnueabi/apr/lib/libapr-1.la -luuid -lrt -lcrypt -lpthread -ldl
/usr/arm-linux-gnueabi/expat/lib/libexpat.so: could not read symbols: File in wrong format
collect2: ld returned 1 exit status
make[1]: *** [libaprutil-1.la] Error 1
make[1]: Leaving directory `/home/jacky/apache/Apache_apr/apr-util-1.5.1'
make: *** [all-recursive] Error 1
非常感谢您的帮助!