我一直在尝试用xerces 3.1.1编译xalan-c特别是1.11。在ubuntu 14.x 64上使用CodeSourcery的arm交叉编译工具链4.3.3。
xalan-c有两个配置脚本。首先是常规/配置和第二/runConfigure。
到目前为止,我一直在使用交叉编译其他库(例如libusb-1.0/libusb-0.1/openssl)
--host../configure --host=arm-none-linux-gnueabi --prefix="/home/user/sysroot-arm-sf/usr/local/"
然而,这次我认为我需要使用/runConfigure否则未设置某些环境变量(例如,它如何处理消息)我使用:
./runConfigure -p linux -x arm-none-linux-gnueabi-g++ -c arm-none-linux-gnueabi-gcc -P "/home/user/sysroot-arm-sf/usr/local/" -C--host=arm-none-linux-gnueabi
相反,我认为这相当于/配置。/runConfigure使用所有默认值(不幸的是,除了它无法识别的c和c++编译器)
Generating makefiles with the following options ...
Platform: linux
C Compiler: arm-none-linux-gnueabi-gcc
C++ Compiler: arm-none-linux-gnueabi-g++
Extra compile options:
Extra link options:
Transcoder: default
Localization system: inmem
Locale: en_US
Thread option: pthread
bitsToBuild option: 32
Extra configure options: --prefix=/home/user/sysroot-arm-sf/usr/local/ --host=arm-none-linux-gnueabi
Debug is OFF
I do not recognize the C compiler 'arm-none-linux-gnueabi-gcc'. Continuing anyway ...
I do not recognize the C++ compiler 'arm-none-linux-gnueabi-g++'. Continuing anyway ...
configure: WARNING: If you wanted to set the --build type, don't use --host.
If a cross compiler is detected then cross compile mode will be used.
checking for arm-none-linux-gnueabi-gcc... arm-none-linux-gnueabi-gcc
checking for C compiler default output file name... a.out
checking whether the C compiler works... yes
checking whether we are cross compiling... yes
checking for suffix of executables...
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether arm-none-linux-gnueabi-gcc accepts -g... yes
checking for arm-none-linux-gnueabi-gcc option to accept ANSI C... none needed
checking for arm-none-linux-gnueabi-g++... arm-none-linux-gnueabi-g++
checking whether we are using the GNU C++ compiler... yes
checking whether arm-none-linux-gnueabi-g++ accepts -g... yes
checking for a BSD-compatible install... /usr/bin/install -c
checking for autoconf... autoconf
checking build system type... x86_64-unknown-linux-gnu
checking host system type... arm-none-linux-gnueabi
checking for floor in -lm... yes
checking how to run the C++ preprocessor... arm-none-linux-gnueabi-g++ -E
checking for egrep... grep -E
checking for ANSI C header files... yes
checking for mbstowcs... yes
checking if mbstowcs can count only... cross-compiling default
configure: creating ./config.status
config.status: creating Makefile.incl
config.status: creating Makefile
config.status: creating src/xalanc/Makefile
config.status: creating src/xalanc/Utils/Makefile
config.status: creating src/xalanc/Utils/MsgCreator/Makefile
config.status: creating src/xalanc/Utils/XalanMsgLib/Makefile
config.status: creating samples/Makefile
config.status: creating Tests/Makefile
If the result of the above commands look OK to you, go to the directory
/home/user/xalan-c-1.11/c/ and type "gmake" or "make" to make the XALAN-C system.
Note: You must use GNU make to use the Xalan Makefile.
那我试试
make
make -C src/xalanc all
make[1]: Entering directory `/home/user/xalan-c-1.11/c/src/xalanc'
Preparing the directory structure for a build ...
mkdir -p ../../obj
mkdir -p ../../lib
mkdir -p ../../bin
make -C Utils prepare
make[2]: Entering directory `/home/user/xalan-c-1.11/c/src/xalanc/Utils'
mkdir -p ../../../nls
mkdir -p ../../../nls/include
make[2]: Leaving directory `/home/user/xalan-c-1.11/c/src/xalanc/Utils'
make -C Utils locale
make[2]: Entering directory `/home/user/xalan-c-1.11/c/src/xalanc/Utils'
make -C MsgCreator
make[3]: Entering directory `/home/user/xalan-c-1.11/c/src/xalanc/Utils/MsgCreator'
arm-none-linux-gnueabi-g++ -O3 -DNDEBUG -pthread -D_REENTRANT -Wall -fPIC -DLINUX -D_REENTRANT -DXALAN_INMEM_MSG_LOADER -c -I/home/user/xalan-c-1.11/c//src -I/home/user/xalan-c-1.11/c//include -I../../../../nls/include -I/home/user/xerces-c-3.1.1//src/ -I/home/user/xerces-c-3.1.1//include/xercesc -I/home/user/xerces-c-3.1.1//include/ -o ../../../../obj/MsgFileOutputStream.o /home/user/xalan-c-1.11/c//src/xalanc/Utils/MsgCreator/MsgFileOutputStream.cpp
arm-none-linux-gnueabi-g++ -O3 -DNDEBUG -pthread -D_REENTRANT -Wall -fPIC -DLINUX -D_REENTRANT -DXALAN_INMEM_MSG_LOADER -c -I/home/user/xalan-c-1.11/c//src -I/home/user/xalan-c-1.11/c//include -I../../../../nls/include -I/home/user/xerces-c-3.1.1//src/ -I/home/user/xerces-c-3.1.1//include/xercesc -I/home/user/xerces-c-3.1.1//include/ -o ../../../../obj/ICUResHandler.o /home/user/xalan-c-1.11/c//src/xalanc/Utils/MsgCreator/ICUResHandler.cpp
arm-none-linux-gnueabi-g++ -O3 -DNDEBUG -pthread -D_REENTRANT -Wall -fPIC -DLINUX -D_REENTRANT -DXALAN_INMEM_MSG_LOADER -c -I/home/user/xalan-c-1.11/c//src -I/home/user/xalan-c-1.11/c//include -I../../../../nls/include -I/home/user/xerces-c-3.1.1//src/ -I/home/user/xerces-c-3.1.1//include/xercesc -I/home/user/xerces-c-3.1.1//include/ -o ../../../../obj/InMemHandler.o /home/user/xalan-c-1.11/c//src/xalanc/Utils/MsgCreator/InMemHandler.cpp
arm-none-linux-gnueabi-g++ -O3 -DNDEBUG -pthread -D_REENTRANT -Wall -fPIC -DLINUX -D_REENTRANT -DXALAN_INMEM_MSG_LOADER -c -I/home/user/xalan-c-1.11/c//src -I/home/user/xalan-c-1.11/c//include -I../../../../nls/include -I/home/user/xerces-c-3.1.1//src/ -I/home/user/xerces-c-3.1.1//include/xercesc -I/home/user/xerces-c-3.1.1//include/ -o ../../../../obj/MsgCreator.o /home/user/xalan-c-1.11/c//src/xalanc/Utils/MsgCreator/MsgCreator.cpp
arm-none-linux-gnueabi-g++ -O3 -DNDEBUG -pthread -D_REENTRANT -Wall -fPIC -DLINUX -D_REENTRANT -DXALAN_INMEM_MSG_LOADER -c -I/home/user/xalan-c-1.11/c//src -I/home/user/xalan-c-1.11/c//include -I../../../../nls/include -I/home/user/xerces-c-3.1.1//src/ -I/home/user/xerces-c-3.1.1//include/xercesc -I/home/user/xerces-c-3.1.1//include/ -o ../../../../obj/NLSHandler.o /home/user/xalan-c-1.11/c//src/xalanc/Utils/MsgCreator/NLSHandler.cpp
arm-none-linux-gnueabi-g++ -O3 -DNDEBUG -pthread -D_REENTRANT -Wall -fPIC -DLINUX -D_REENTRANT -DXALAN_INMEM_MSG_LOADER -c -I/home/user/xalan-c-1.11/c//src -I/home/user/xalan-c-1.11/c//include -I../../../../nls/include -I/home/user/xerces-c-3.1.1//src/ -I/home/user/xerces-c-3.1.1//include/xercesc -I/home/user/xerces-c-3.1.1//include/ -o ../../../../obj/SAX2Handler.o /home/user/xalan-c-1.11/c//src/xalanc/Utils/MsgCreator/SAX2Handler.cpp
arm-none-linux-gnueabi-g++ -DLINUX -fPIC -pthread -D_REENTRANT -DXALAN_INMEM_MSG_LOADER
-lm -lpthread ../../../../obj/MsgFileOutputStream.o ../../../../obj/ICUResHandler.o ../../../../obj/InMemHandler.o ../../../../obj/MsgCreator.o ../../../../obj/NLSHandler.o ../../../../obj/SAX2Handler.o -o ../../../../bin/MsgCreator -L/home/user/xerces-c-3.1.1//lib -lxerces-c
make[3]: Leaving directory `/home/user/xalan-c-1.11/c/src/xalanc/Utils/MsgCreator'
../../../bin/MsgCreator /home/user/xalan-c-1.11/c//src/xalanc/NLS/en_US/XalanMsg_en_US.xlf -TYPE inmem -LOCALE en_US
../../../bin/MsgCreator: ../../../bin/MsgCreator: cannot execute binary file
make[2]: *** [../../../nls/include/LocalMsgData.hpp] Error 126
make[2]: Leaving directory `/home/user/xalan-c-1.11/c/src/xalanc/Utils'
make[1]: *** [locale] Error 2
make[1]: Leaving directory `/home/user/xalan-c-1.11/c/src/xalanc'
make: *** [all] Error 2
并且它将无法执行
../../../bin/MsgCreator /home/user/xalan-c-1.11/c//src/xalanc/NLS/en_US/XalanMsg_en_US.xlf -TYPE inmem -LOCALE en_US
哪个是
bin/MsgCreator: ELF 32-bit LSB executable, ARM, EABI5 version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.14, not stripped
臂拱的二进制值。我想/runConfigure使用了--host选项,并意识到这是一个交叉构建。或者这可能是xalan-c特异性的东西?
它确实说
checking whether we are cross compiling... yes
所以对我来说,这看起来像是一个测试不好的makefile
你可以试着调试它,也可以安装qemu,让ARM二进制文件神奇地工作(假设它们能找到自己的库)。
我尝试了以下解决方法,显然有效。
xalanc-bin/Folder中的文件似乎只在编译时使用(至少我猜是这样)。Xalan生成头文件等以便编译libxalanMsg.so.
这是一个很长的机会,但我只是为Ubuntu x86预编译这些bin/文件,并将这些文件复制到我的交叉编译bin文件夹中。
完成。(至少目前)
这个问题真的很棘手,也很奇怪。幸运的是,我找到了解决这个问题的方法。从错误中,我们可以得出结论,构建过程使用了一个名为"MsgCreator"的可执行工具。
它来自哪里
实际上,这个工具是构建过程的中间产品。Xalan生成它并使用这个工具来做他想做的事情。
会发生什么
您可能还记得,您现在正在交叉编译Xalan,因此MsgCreator的目标可执行平台可能不支持您的构建平台。这种情况将导致您看到的错误。
如何解决此问题
- 使用本地编译器构建本地MsgCreator,这意味着该工具可以在您的构建平台上运行
- 更新…中的代码/xalan-c-1.11/c/src/xalan/Utils/MsgCreator/Malefile.in。$(XSL_BIN_DIR)/MsgCreator->$(XSL-BIN_TMP_DIR)/MsgCreator
- 将XSL_BIN_TMP_DIR导出到本地MsgCreator工具路径
- 导出LD_LIBRARY_PATH以添加MsgCreator依赖库。这些库可以通过使用本地编译器编译Xerces-C(版本必须大于3.0)来生成
- 交叉编译Xalan,一切都会很顺利