bluez5.50交叉编译

版权声明:转载请注明出处 https://blog.csdn.net/u010659887/article/details/85115625

编译环境:ubuntu14.04

编译工具:arm-none-linux-gnueabi-gcc

参考文档https://blog.csdn.net/gatieme/article/details/48751743

这个文档说的很详细,但是编译的是低版本的bluez,下面是编译bluez5.50中遇到的问题

总体思路:交叉编译过程中遇到提示缺少的库就去下载编译,有些库不是必须的,可以在configure的参数中设置该项为disable,具体执行./configure --help查看。

问题1:configure: error: C compiler cannot create executables

在安装完编译工具链后,需要配置环境变量,但是配置变量实在用户权限下,而执行用的sudo所以配置完也可能找不到,所以干脆使用绝对路径,如下:

sudo ./configure --prefix=/opt/arm/bluez --host=arm-none-linux --target=arm-none-linux CC=/usr/local/arm-2014.05/bin/arm-none-linux-gnueabi-gcc

问题2:No package 'expat' found

正常交叉编译完expat后,在交叉编译dbus的时候提示No package 'expat' found,安装下面两个库

sudo apt-get install libexpat1
sudo apt-get install libexpat1-dev

问题3:can't faind -lgib

正常情况下dbus不会依赖glib,这里提示找不到-lgib库是因为dbus的test程序里对glib库有依赖,test里是些demon,编译库用不到。所以在configure时加上--disable-tests参数直接跳过。后面编译glib的时候发现对dbus也有依赖,这里不注意的话这两库谁也编译不了。

扫描二维码关注公众号,回复: 4581592 查看本文章

问题4:cannot run test program while cross compiling

configure glib4.2的时候会生成测试文件,因为环境的问题无法生成,需要配置环境,如下:

sudo ./configure --prefix=/opt/arm/bluez --host=arm-none-linux-gnueabi --target=arm-none-linux-gnueabi  CC="/usr/local/arm-2014.05/bin/arm-none-linux-gnueabi-gcc -I/opt/arm/bluez/include -L/opt/arm/bluez/lib" --cache-file=arm-linux.cache glib_cv_long_long_format=ll glib_cv_stack_grows=no glib_cv_have_strlcpy=no glib_cv_have_qsort_r=yes glib_cv_va_val_copy=yes glib_cv_uscore=no glib_cv_rtldglobal_broken=no ac_cv_func_posix_getpwuid_r=yes ac_cv_func_posix_getgrgid_r=yes

问题5:编译bluez提示有未定义的某个glib中的api

如果是can't find -lgib那是缺少glib库,如果已经编译了glib,还提示有未定义的glib api肯定是当前使用的glib版本太老了,需要使用新版本的glib。(PS:我用的是glib4.2,再低的应该不能匹配bluez5.50了)

问题6:编译完bluez后没有生成.so和.a文件

bluez5.5默认的configure配置不会生成so和a文件,需要配置,如下:

sudo ./configure --prefix=/opt/arm/bluez --host=arm-none-linux-gnueabi --target=arm-none-linux-gnueabi    CC="/usr/local/arm-2014.05/bin/arm-none-linux-gnueabi-gcc -I/opt/arm/bluez/include -L/opt/arm/bluez/lib" --sysconfdir=/etc --localstatedir=/var --enable-experimental --with-systemdsystemunitdir=/lib/systemd/system --with-systemduserunitdir=/usr/lib/systemd --disable-client --enable-network --enable-health --enable-tools --enable-tools --enable-bccmd --enable-cups --enable-test --enable-library --enable-static=yes --enable-shared=yes --enable-threads --enable-pie

上面这些当然不是编译过程遇到的全部问题,剩下的都是缺少某个某个头文件和链接库的问题,这种问题不用纠结,直接下载对应的库继续交叉编译吧,再遇到的问题网上基本都有了。

猜你喜欢

转载自blog.csdn.net/u010659887/article/details/85115625