我正在交叉编译ocaml校准应用程序随附的触摸屏驱动程序。

我正在尝试为运行Angström的ARM(尤其是Beagleboard)编译驱动程序和应用程序。

它是这样的:

^_^[raziel@Bebop zytouch-driver-20081121]$ source /usr/local/angstrom/arm/environment-setup
^_^[raziel@Bebop zytouch-driver-20081121]$ make CC=arm-angstrom-linux-gnueabi-gcc
arm-angstrom-linux-gnueabi-gcc -std=gnu99 -g -O2 -Wall -Wextra -Werror -Wstrict-prototypes -Wmissing-prototypes   -c -o daemon/config.o daemon/config.c
arm-angstrom-linux-gnueabi-gcc -std=gnu99 -g -O2 -Wall -Wextra -Werror -Wstrict-prototypes -Wmissing-prototypes   -c -o daemon/util.o daemon/util.c
arm-angstrom-linux-gnueabi-gcc -std=gnu99 -g -O2 -Wall -Wextra -Werror -Wstrict-prototypes -Wmissing-prototypes   -c -o daemon/debug.o daemon/debug.c
arm-angstrom-linux-gnueabi-gcc -std=gnu99 -g -O2 -Wall -Wextra -Werror -Wstrict-prototypes -Wmissing-prototypes   -c -o daemon/zytouch_usb.o daemon/zytouch_usb.c
arm-angstrom-linux-gnueabi-gcc -std=gnu99 -g -O2 -Wall -Wextra -Werror -Wstrict-prototypes -Wmissing-prototypes   -c -o daemon/zytouchd.o daemon/zytouchd.c
arm-angstrom-linux-gnueabi-gcc daemon/config.o daemon/util.o daemon/debug.o daemon/zytouch_usb.o daemon/zytouchd.o -lX11 -lXtst -lusb -lm -o zytouch-daemon
ocamlopt -cc arm-angstrom-linux-gnueabi-gcc -cclib -lcairo -cclib -lextlib -cclib -llablgtk2 -warn-error A -c -I +lablgtk2 -I +cairo -I +extlib -I calibrate calibrate/version.ml -o calibrate/version.cmx
ocamlopt -cc arm-angstrom-linux-gnueabi-gcc -cclib -lcairo -cclib -lextlib -cclib -llablgtk2 -warn-error A -c -I +lablgtk2 -I +cairo -I +extlib -I calibrate calibrate/util.ml -o calibrate/util.cmx
ocamlopt -cc arm-angstrom-linux-gnueabi-gcc -cclib -lcairo -cclib -lextlib -cclib -llablgtk2 -warn-error A -c -I +lablgtk2 -I +cairo -I +extlib -I calibrate calibrate/config.ml -o calibrate/config.cmx
ocamlopt -cc arm-angstrom-linux-gnueabi-gcc -cclib -lcairo -cclib -lextlib -cclib -llablgtk2 -warn-error A -c -I +lablgtk2 -I +cairo -I +extlib -I calibrate calibrate/orientation.ml -o calibrate/orientation.cmx
ocamlopt -cc arm-angstrom-linux-gnueabi-gcc -cclib -lcairo -cclib -lextlib -cclib -llablgtk2 -warn-error A -c -I +lablgtk2 -I +cairo -I +extlib -I calibrate calibrate/tscalibrate.ml -o calibrate/tscalibrate.cmx
ocamlopt -cc arm-angstrom-linux-gnueabi-gcc -cclib -lcairo -cclib -lextlib -cclib -llablgtk2 -warn-error A -cc arm-angstrom-linux-gnueabi-gcc -cclib -lcairo -cclib -lextlib -cclib -llablgtk2 -warn-error A -I +lablgtk2 -I +cairo -I +extlib -I calibrate extLib.cmxa str.cmxa unix.cmxa lablgtk.cmxa cairo_lablgtk.cmxa cairo.cmxa gtkInit.cmx calibrate/version.cmx calibrate/util.cmx calibrate/config.cmx calibrate/orientation.cmx calibrate/tscalibrate.cmx -o zytouch-calibrate
/usr/local/angstrom/arm/lib/gcc/arm-angstrom-linux-gnueabi/4.3.3/../../../../arm-angstrom-linux-gnueabi/bin/ld: /tmp/camlstartup71ef32.o: Relocations in generic ELF (EM: 3)
/usr/local/angstrom/arm/lib/gcc/arm-angstrom-linux-gnueabi/4.3.3/../../../../arm-angstrom-linux-gnueabi/bin/ld: /tmp/camlstartup71ef32.o: Relocations in generic ELF (EM: 3)
/tmp/camlstartup71ef32.o: could not read symbols: File in wrong format
collect2: ld returned 1 exit status
File "caml_startup", line 1, characters 0-1:
Error: Error during linking
make: *** [zytouch-calibrate] Error 2

我陷入了Relocations in generic ELF (EM: 3)错误。

Makefile如下所示:
(...)
OFLAGS = -cc ${CC} -cclib -lcairo -cclib -lextlib -cclib -llablgtk2 -warn-error A
OCAMLOPT = ocamlopt $(OFLAGS)

OCAML_INC =  -I +lablgtk2 -I +cairo -I +extlib -I calibrate
OCAML_LIBS = $(OCAML_INC) extLib.cmxa str.cmxa unix.cmxa lablgtk.cmxa cairo_lablgtk.cmxa cairo.cmxa gtkInit.cmx

(...)
config.cmx: util.cmx
orientation.cmx: config.cmx
tscalibrate.cmx: version.cmx util.cmx orientation.cmx config.cmx

%.cmx : %.ml
        $(OCAMLOPT) -c $(OCAML_INC) $< -o $@

%.mli : %.ml
        $(OCAMLC) -i $(OCAML_INC) $+

由于/usr/local/angstrom/arm/environment-setup/usr/local/angstrom/arm/bin保留为PATH的第一个元素,因此我尝试将某些程序替换为ARM版本
sudo ln -s /usr/local/angstrom/arm/bin/arm-angstrom-linux-gnueabi-ar /usr/local/angstrom/arm/bin/ar
sudo ln -s /usr/local/angstrom/arm/bin/arm-angstrom-linux-gnueabi-as /usr/local/angstrom/arm/bin/as
sudo ln -s /usr/local/angstrom/arm/bin/arm-angstrom-linux-gnueabi-ld /usr/local/angstrom/arm/bin/ld

但是,在替换as之后,这些模块甚至无法编译
ocamlopt -cc arm-angstrom-linux-gnueabi-gcc -cclib -lcairo -cclib -lextlib -cclib -llablgtk2 -warn-error A -c -I +lablgtk2 -I +cairo -I +extlib -I calibrate calibrate/version.ml -o calibrate/version.cmx
/tmp/camlasm41bb77.s: Assembler messages:
/tmp/camlasm41bb77.s:31: Error: alignment too large: 15 assumed
/tmp/camlasm41bb77.s:35: Error: bad instruction `movl $camlVersion__3,%eax'
/tmp/camlasm41bb77.s:36: Error: bad instruction `movl %eax,camlVersion'
/tmp/camlasm41bb77.s:37: Error: bad instruction `movl $camlVersion__2,%eax'
/tmp/camlasm41bb77.s:38: Error: bad instruction `movl %eax,camlVersion+4'
/tmp/camlasm41bb77.s:39: Error: bad instruction `movl $camlVersion__1,%eax'
/tmp/camlasm41bb77.s:40: Error: bad instruction `movl %eax,camlVersion+8'
/tmp/camlasm41bb77.s:41: Error: bad instruction `movl $1,%eax'
/tmp/camlasm41bb77.s:42: Error: bad instruction `ret'
/tmp/camlasm41bb77.s:43: Error: unrecognized symbol type ""
File "calibrate/version.ml", line 1, characters 0-1:
Error: Assembler error, input left in file /tmp/camlasm41bb77.s
make: *** [calibrate/version.cmx] Error 2

我敢肯定这一定是一个非常愚蠢的错误,但是我找不到有关如何正确执行此操作的文档。有谁知道可能会失败吗?

我要构建的驱动程序的源代码可以在here中找到。

最佳答案

ocaml当前不支持交叉编译,并且传递-cc选项不会使其神奇地进行交叉编译。周围有一些补丁可以使之成为可能,但没有正式的补丁。我记得使用修补的ocamlopt,它对于简单的程序也能正常工作。但是在这种情况下,您还需要交叉编译所有依赖的库,这可能是一项艰巨的任务。

我认为您最好的解决方案是:

  • native 构建在 ARM qemu中(这很容易,有预构建的debian镜像available)
  • 构建一个校准应用程序的字节码二进制文件(该字节码可在两种体系结构之间移植,但需要在目标上安装相同版本的ocaml),并在臂上安装所需的 stub 库(包含用于绑定(bind)到gtk,cairo等的C代码的 stub 库)(本地构建或从软件包构建)
  • 关于arm - 交叉编译ARM的ocaml应用,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/9472371/

    10-16 04:50