1、交叉编译cups(ARM-LINUX) 2010-10-11 17:00:59| 分类: Linux操作系统|举报|字号 订阅 最近研究下如何交叉编译 CUPS,期间碰到很多编译上的问题,google一下,也没有见到详细的关于交叉编译cups的文档。自己根据网上的一些帖子,一点一点的研究编译中出 现的问题,今天终于完成了。这里就说下交叉编译CUPS的过程和当中遇到的问题。 一:交叉编译环境 我使用的是gcc-4.1.1,制作交叉编译环境用到了如下的文件: binutils-2.16.1 Download URL: ftp://ftp.gnu.org
2、 gdb-6.5 Download URL: ftp://ftp.gnu.org gcc-3.3.6 Download URL: ftp://ftp.gnu.org glibc-2.3.2 Download URL: ftp://ftp.gnu.org linux-2.6.24 Download URL: http://www.kernel.org linux-libc-headers-2.6.12.0 Download URL:http://ep09.pld-linux.org/~mma
3、zur/linux-libc-headers/ 使用crosstool-0.43工具进行编译,生成我的交叉编译环境。(从 crosstool-0.43) 二:CUPS版本 cups-1.3.9-source.tar.gz Download URL: http://www.cups.org/software.php 三: 步骤 1、交叉编译工具放置位置 1.1 将交叉编译工具目录(4.1.1,一般而言,交叉编译目录以GCC版本号命名)放置到/usr/local/arm/下面(如果没有arm目录,则新建 之); 1
4、2 编辑/etc/profile文件,加入/usr/local/arm/4.1.1/bin的路径 pathmunge /usr/local/arm/4.1.1/bin 然后,执行source /etc/profile或者重新启动电脑,使得相关路径添加到PATH中。 2、解压cups到一个目录中(您可以自己指定); 3、cd cups-1.3.9/,进入cups目录; 4、configure,指令如下: ./configure CC=arm-linux-gnueabihf-gcc CX
5、X=arm-linux-gnueabihf-g++ LD=arm-linux-gnueabihf-ld RANLIB=arm-linux-gnueabihf-ranlib AR=arm-linux-gnueabihf-ar --target=arm-linux --host=arm-linux --build=i686-linux --disable-gnutls --disable-gssapi --disable-dbus --prefix=/ 执行完成之后,会生成一个Makedefs文件,这个名称给Makefile使用。头文件和库文件的修改,都在这个文件中进行。Makef
6、ile文件在 configure过程中,不会自动生成,它是不变的。 在configure的过程中遇到很多问题。现在说下我解决的方法: 问题1:库连接错误(找不到xxx库) /usr/local/arm/4.1.1/bin/../lib/gcc/arm-linux/4.1.1/../../../../arm-linux/bin/ld: cannot find -lgnutls 我本想交叉编译gnutls,生成相关的库,但是交叉编译gnutls失败,网上暂时也找不到gnutls交叉编译库的内容,所以这个暂时放在一边。
7、 修改方法: 添加编译选项:--disable-gnutls(含义:使得gnutls选项无效) 在文件Makedefs文件中,SSLLIBS = -lgnutls表示需要SSL库支持。 问题2: In file included from cupsd.h:121, from auth.c:57: cert.h:28: error: expected specifier-qualifier-list before 'krb
8、5_ccache' In file included from cupsd.h:127, from auth.c:57: job.h:60: error: expected specifier-qualifier-list before 'krb5_ccache' In file included from auth.c:57: cupsd.h:164: error: expected '=', ',', ';', 'asm' or '__attribute__' before '
9、KerberosContext' auth.c: In function 'cupsdAuthorize': auth.c:561: error: 'cupsd_cert_t' has no member named 'ccache' make[1]: *** [auth.o] 错误 1 make: *** [all] 错误 1 这个应该是头文件的问题。这个问题与gssapi有关,暂时没有解决。可以查看Makedefs文件中的 LIBGSSAPI = -lgssapi_k
10、rb5 -lkrb5 -lk5crypto -lcom_err -lresolv -ldl 改行说明需要gssapi库的支持。 解决方法:--disable-gssapi 问题3: /usr/local/arm/4.1.1/bin/../lib/gcc/arm-linux/4.1.1/../../../../arm-linux/bin/ld: skipping incompatible /lib/libdbus-1.so when searching for -ldbus-1 /usr/local/arm/
11、4.1.1/bin/../lib/gcc/arm-linux/4.1.1/../../../../arm-linux/bin/ld: cannot find -ldbus-1 与问题一类似。 在Makedefs文件中,CUPSDLIBS = -L/lib -ldbus-1表示cups库支持。 解决方法:--disable-dbus 这里对问题的解决,主要是对相关库的连接属性进行修改,后期将对这个库的编译作一个研究,并加入进来,使得CUPS的编译更加完整。实际上,在将cups 移植到开发板的时候,
12、部分功能可以不要,当然相关库也可以不用,使用--disable选项可以取消某些库的使用。 5、make 5.1 修改Makefile文件,将 DIRS = cups backend berkeley cgi-bin filter locale man monitor \ notifier $(PDFTOPS) scheduler systemv test \ $(PHPDIR) \ con
13、f data doc $(FONTS) ppd templates 修改为: DIRS = cups backend berkeley cgi-bin filter locale monitor \ notifier $(PDFTOPS) scheduler systemv test \ $(PHPDIR) \ conf data doc $(FONTS) ppd templates 即,去掉m
14、an 取消对man文件编译。否则会出现如下的错误: Compiling mantohtml.c... Converting man pages to HTML... cancel.1.gz... /bin/sh: line 2: ./mantohtml: cannot execute binary file cups-config.1.gz... /bin/sh: line 2: ./mantohtml: cannot execute binary file
15、 cupstestdsc.1.gz... /bin/sh: line 2: ./mantohtml: cannot execute binary file cupstestppd.1.gz... /bin/sh: line 2: ./mantohtml: cannot execute binary file lp.1.gz... /bin/sh: line 2: ./mantohtml: cannot execute binary file lpoption
16、s.1.gz... /bin/sh: line 2: ./mantohtml: cannot execute binary file lppasswd.1.gz... /bin/sh: line 2: ./mantohtml: cannot execute binary file lpq.1.gz... /bin/sh: line 2: ./mantohtml: cannot execute binary file lprm.1.gz... /bin/sh:
17、line 2: ./mantohtml: cannot execute binary file lpr.1.gz... /bin/sh: line 2: ./mantohtml: cannot execute binary file lpstat.1.gz... /bin/sh: line 2: ./mantohtml: cannot execute binary file make[1]: *** [html] 错误 126 make: *** [all] 错误 1 做完修改后,make可以正常进行。






