精华内容
下载资源
问答
  • 交叉编译dbus

    2021-05-21 23:37:12
    交叉编译dbus 1. 下载dbus和expat源码 dbus: http://dbus.freedesktop.org/releases/dbus/ expat: http://sourceforge.net/projects/expat/ 2. 交叉编译expat #./configure --host=armv6-rpi-linux-gnueabi --...

    交叉编译dbus

    1. 下载dbus和expat源码
    dbus:  http://dbus.freedesktop.org/releases/dbus/
    
    expat: http://sourceforge.net/projects/expat/
    
    2. 交叉编译expat
    #./configure --host=armv6-rpi-linux-gnueabi --prefix=/opt/Rasp/expat
    $ ./configure --prefix=/usr/aarch64-linux-gnu --host=aarch64-linux-gn  (我用的命令)
    #make -j8
    #make install
    
    3. 交叉编译dbus
    #./configure --host=armv6-rpi-linux-gnueabi --prefix=/opt/Rasp/dbus CFLAGS=-I/opt/Rasp/expat/include LDFLAGS=-L/opt/Rasp/expat/lib
    $ ./configure --prefix=/usr/aarch64-linux-gnu --host=aarch64-linux-gnu CFLAGS=-I/usr/aarch64-linux-gnu/include LDFLAGS=-L/usr/aarch64-linux-gnu/lib  (我用的命令)
    #make -j8
    #make install
    

    参考:

    make -j8编译dbus时报错如下:

    make[3]: *** [Makefile:1245:test-dbus-daemon-eavesdrop] 错误 1
    /usr/lib/gcc-cross/aarch64-linux-gnu/8/../../../../aarch64-linux-gnu/bin/ld: cannot find -lgio-2.0
    /usr/lib/gcc-cross/aarch64-linux-gnu/8/../../../../aarch64-linux-gnu/bin/ld: cannot find -lgobject-2.0
    /usr/lib/gcc-cross/aarch64-linux-gnu/8/../../../../aarch64-linux-gnu/bin/ld: cannot find -lglib-2.0
    collect2: error: ld returned 1 exit status
    
    

    这种情况是由于缺少libz导致,所以需要安装交叉编译的zlib库,参考:

    展开全文
  • 文章目录1、编译说明2、环境准备3、交叉编译dbus3.1 编译expat3.2 编译dbus4、交叉编译dbus-glib4.1 先编译glib4.1.1 libffi(版本需>=3.0)4.1.2 zlib4.1.3 glib4.2 编译dbus-glib5、可能会遇到的问题5.1 编译...

    1、编译说明

    打开dbus官网,可以看到“What is D-Bus?”章节有以下说明:

    The low-level libdbus reference library has no required dependencies; the reference bus daemon’s only required dependency is an XML parser (expat). Higher-level bindings specific to particular frameworks (Qt, GLib, Java, C#, Python, etc.) add more dependencies, but can make more assumptions and are thus much simpler to use.

    意思大概就是编译dbus只需要依赖第三方XML库(expat),高级的封装才会依赖更多的库。而文章接下来介绍使用arm-linux-gnueaihf-来交叉编译dbus和它的高级封装dbus-glib。关于dbus的交叉编译,可以从dbus源码包的README文件了解:

    Bootstrapping D-Bus on new platforms

    A full build of D-Bus, with all regression tests enabled and run, has some
    dependencies which themselves depend on D-Bus, either for compilation or
    for some of their regression tests: GLib, dbus-glib and dbus-python are
    currently affected.

    To avoid circular dependencies, when bootstrapping D-Bus for the first time
    on a new OS or CPU architecture, you can either cross-compile some of
    those components, or choose the build order and options carefully:

    • build and install D-Bus without tests
      • do not use the --enable-modular-tests=yes configure option
      • do not use the --enable-tests=yes configure option
    • build and install GLib, again without tests
    • use those versions of libdbus and GLib to build and install dbus-glib
    • … and use those to install dbus-python
    • rebuild libdbus; this time you can run all of the tests
    • rebuild GLib; this time you can run all of the tests

    意思大概就是在新的平台中引入D-bus时(通俗的说就是交叉编译),为了避免更多的依赖,在交叉编译dbus的时候就不能引入更多tests目录下的测试程序(当时编译没注意到这点走了不少弯路啊!!!)。通过./configure --help查看配置帮助信息可以看到以下选项:

      --enable-embedded-tests enable unit test code in the library and binaries
      --enable-modular-tests  enable modular regression tests (requires GLib)
      --enable-tests          enable/disable all tests, overriding
                              embedded-tests/modular-tests
    

    所以在./configure配置为交叉编译的时候就可以加上--enable-tests=no选项来覆盖embedded-tests/modular-tests这两个选项的配置,从而达到不引入tests测试程序的目的。

    另外,编译第三方库时,它又会依赖其他库的时候,可以在./configure命令时使用CFLAGS、LDFLAGS、XXX_CFLAGS和XXX_LIBS来指定编译好的依赖库。但如果依赖库与头文件路径较多时,手动设置这些变量就会比较的麻烦,这时就可以使用pkg-config程序来帮助我们完成这些填写,我们只需要把第三方库的xxx.pc所在路径添加到PKG_CONFIG_PATH这个环境变量中即可。接下来的编译步骤里这个两种方法是都会用上。更多关于pkg-config的用法可以参考文章《Linux:pkg-config的一些用法》


    2、环境准备

    sudo apt-get install autoconf autoconf-archive libtool pkg-config libglib2.0-dev
    

    3、交叉编译dbus

    源码包下载:地址

    3.1 编译expat

    dbus需要依赖一个XML解析器–expat,所以需要先编译expat得到依赖库。

    下载地址:https://github.com/libexpat/libexpat/releases

    tar xjf expat-2.3.0.tar.bz2
    cd expat-2.3.0/
    ./configure --prefix=$PWD/tmp --host=arm-linux-gnueabihf
    make
    make install
    

    3.2 编译dbus

    下载地址:

    tar xzf dbus-1.12.20.tar.gz
    cd dbus-1.12.20/
    export PKG_CONFIG_PATH=$PKG_CONFIG_PATH:$PWD/../expat-2.3.0/tmp/lib/pkgconfig
    ./autogen.sh
    ./configure --prefix=$PWD/tmp --host=arm-linux-gnueabihf --enable-tests=no
    make
    make install
    

    到了这一步,关于dbus的移植就基本完成了,下面的都是关于dbus-glib和它的一些依赖的移植,可以不用往下看,不影响后面文章的学习。但是另外有一点,这里的编译步骤可能会导致程序在目标板运行的时候出现主机路径的问题,所以这里的步骤只能是先了解大体步骤,dbus详细的移植与使用可以跳到【这篇文章】


    4、交叉编译dbus-glib

    4.1 先编译glib

    要想编译glib必须先编译它依赖的两个库(libffi和zlib):

    4.1.1 libffi(版本需>=3.0)

    下载地址:https://sourceware.org/libffi/

    tar xzf libffi-3.3.tar.gz
    cd libffi-3.3/
    ./configure --prefix=$PWD/tmp --host=arm-linux-gnueabihf
    make
    make install
    

    4.1.2 zlib

    下载地址:http://zlib.net/

    tar xzf zlib-1.2.11.tar.gz
    cd zlib-1.2.11/
    ./configure --prefix=$PWD/tmp 		# 不支持在这里指定CC
    sed -i 's/=gcc/=arm-linux-gnueabihf-gcc/g' Makefile # 修改gcc为交叉编译的gcc,加“=”防止重复替换
    make
    make install
    

    4.1.3 glib

    下载地址:ftp://ftp.acc.umu.se/pub/gnome/sources/glib/

    参考文档:

    • INSTALL
    • docs/reference/glib/html/glib-cross-compiling.html
    tar xJf glib-2.34.1.tar.xz
    cd glib-2.34.1/
    vi cross_compile.cache 	# 新建文件的内容在下方给出
    # 注意:这里不需要执行./autogen.sh
    # 不知道是环境没配好,还是官方本身就不维护,因为INSTALL文档的步骤里也不用
    # 还有一点就是执行./autogen.sh不就是为了生成configure嘛,已经提供了也不需要再次生成
    ./configure --prefix=$PWD/tmp --host=arm-linux-gnueabihf \
    	LIBFFI_CFLAGS=-I$PWD/../libffi-3.3/tmp/include \
    	LIBFFI_LIBS="-lffi -L$PWD/../libffi-3.3/tmp/lib" \
    	ZLIB_CFLAGS=-I$PWD/../zlib-1.2.11/tmp/include \
    	ZLIB_LIBS="-lz -L$PWD/../zlib-1.2.11/tmp/lib" \
    	--cache-file=cross_compile.cache
    make
    make install
    

    cross_compile.cache内容如下:

    glib_cv_long_long_format=ll
    glib_cv_stack_grows=no
    glib_cv_working_bcopy=yes
    glib_cv_sane_realloc=yes
    glib_cv_have_strlcpy=no
    glib_cv_have_qsort_r=no
    glib_cv_va_val_copy=yes
    glib_cv_rtldglobal_broken=yes
    glib_cv_uscore=yes
    ac_cv_func_posix_getpwuid_r=yes
    ac_cv_func_nonposix_getpwuid_r=yes
    ac_cv_func_posix_getgrgid_r=yes
    glib_cv_use_pid_surrogate=yes
    ac_cv_func_printf_unix98=no
    ac_cv_func_vsnprintf_c99=no
    

    4.2 编译dbus-glib

    下载地址:https://dbus.freedesktop.org/releases/dbus-glib/

    tar xzf dbus-glib-0.106.tar.gz
    cd dbus-glib-0.106/
    export PKG_CONFIG_PATH=$PKG_CONFIG_PATH:$PWD/../glib-2.34.1/tmp/lib/pkgconfig
    export PKG_CONFIG_PATH=$PKG_CONFIG_PATH:$PWD/../dbus-1.12.20/tmp/lib/pkgconfig
    ./configure --prefix=$PWD/tmp --host=arm-linux-gnueabihf \
    	CFLAGS="-I$PWD/../expat-2.3.0/tmp/include" \
    	LDFLAGS="-lexpat -L$PWD/../expat-2.3.0/tmp/lib"
    vi ./dbus/Makefile
    	SUBDIRS = . examples 改为 SUBDIRS = . #examples
    vi ./Makefile
    	SUBDIRS = dbus tools test doc 改为 SUBDIRS = dbus #tools test doc
    make
    make install
    

    5、可能会遇到的问题

    5.1 编译dbus出错

    a. make编译出错:

    /usr/include/glib-2.0/glib/gmacros.h:232:53: error: size of array ‘_GStaticAssertCompileTimeAssertion_0’ is negative
     #define G_STATIC_ASSERT(expr) typedef char G_PASTE (_GStaticAssertCompileTimeAssertion_, __COUNTER__)[(expr) ? 1 : -1] G_GNUC_UNUSED
    

    解决:在./configure ...时配置交叉编译dbus时加上--enable-tests=no选项,原因文章开头已经说了。

    参考文章:dbus源码/README

    5.2 编译glib出错

    a. configure配置时出错:

    checking for glib-genmarshal... no
    configure: error: Could not find a glib-genmarshal in your PATH
    

    解决:

    sudo apt-get install libglib2.0-dev
    

    参考文章:glib配置错误 - Gfim.CSDN

    5.3 编译dbus-glib出错

    a. make编译出错情况1:

    Making all in examples
    make[3]: Entering directory '/home/book/work/opensrc/dbus/dbus-glib-0.106/dbus/examples'
    /bin/bash ../../libtool --mode=execute ../../dbus/dbus-binding-tool --prefix=some_object --mode=glib-server --output=example-service-glue.h ./example-service.xml
    /home/book/work/opensrc/dbus/dbus-glib-0.106/dbus/examples/../../dbus/dbus-binding-tool: line 117: /home/book/work/opensrc/dbus/dbus-glib-0.106/dbus/.libs/lt-dbus-binding-tool: cannot execute binary file: Exec format error
    /home/book/work/opensrc/dbus/dbus-glib-0.106/dbus/examples/../../dbus/dbus-binding-tool: line 117: /home/book/work/opensrc/dbus/dbus-glib-0.106/dbus/.libs/lt-dbus-binding-tool: Success
    Makefile:788: recipe for target 'example-service-glue.h' failed
    make[3]: *** [example-service-glue.h] Error 126
    

    解决:

    vi ./dbus/Makefile
    	SUBDIRS = . examples 改为 SUBDIRS = . #examples
    

    参考文章:How to run dbus and obex-data-server on ARM-xScale - stevenliyong.CSDN

    b. make编译出错情况2:

    Making all in tools
    make[2]: Entering directory '/home/book/work/opensrc/dbus/dbus-glib-0.106/tools'
    ../dbus/dbus-binding-tool --mode=glib-client --prefix=dbus_bus --output=dbus-glib-bindings.h ../dbus-bus-introspect.xml
    ../dbus/dbus-binding-tool: line 117: /home/book/work/opensrc/dbus/dbus-glib-0.106/dbus/.libs/lt-dbus-binding-tool: cannot execute binary file: Exec format error
    ../dbus/dbus-binding-tool: line 117: /home/book/work/opensrc/dbus/dbus-glib-0.106/dbus/.libs/lt-dbus-binding-tool: Success
    Makefile:598: recipe for target 'dbus-glib-bindings.h' failed
    make[2]: *** [dbus-glib-bindings.h] Error 126
    

    解决:

    vi ./Makefile
    	SUBDIRS = dbus tools test doc 改为 SUBDIRS = dbus #tools test doc
    

    参考文章:How to run dbus and obex-data-server on ARM-xScale - stevenliyong.CSDN


    6、编译自己编写的dbus-glib程序

    export PKG_CONFIG_PATH=$PKG_CONFIG_PATH:YOUR_DIR/expat-2.3.0/tmp/lib/pkgconfig
    export PKG_CONFIG_PATH=$PKG_CONFIG_PATH:YOUR_DIR/libffi-3.3/tmp/lib/pkgconfig
    export PKG_CONFIG_PATH=$PKG_CONFIG_PATH:YOUR_DIR/zlib-1.2.11/tmp/lib/pkgconfig
    export PKG_CONFIG_PATH=$PKG_CONFIG_PATH:YOUR_DIR/glib-2.34.1/tmp/lib/pkgconfig
    export PKG_CONFIG_PATH=$PKG_CONFIG_PATH:YOUR_DIR/dbus-1.12.20/tmp/lib/pkgconfig
    export PKG_CONFIG_PATH=$PKG_CONFIG_PATH:YOUR_DIR/dbus-glib-0.106/tmp/lib/pkgconfig
    
    arm-linux-gnueabihf-gcc test.c -o test `pkg-config --cflags --libs glib-2.0 dbus-1 dbus-glib-1 expat libffi gmodule-2.0 zlib gio-2.0 gthread-2.0`
    

    参考文章

    展开全文
  • 编译dbus软件时,出现以下错误: No package 'expat' found 解决过程记录: =========================================================== 解决办法一: 下载软件: wget ...

     

    编译dbus软件时,出现以下错误:

    No package 'expat' found

     

     

    解决过程记录:

    ===========================================================

    解决办法一:

    下载软件:

    wget http://sourceforge.net/projects/expat/files/expat/2.1.0/expat-2.1.0.tar.gz

    tar -xzf expat-2.1.0.tar.gz

    cd expat-2.1.0/

    ./configure --host=arm-linux-gnueabi --prefix=/usr/arm-linux-gnueabi

    make

    sudo make install

    此办法无效,不能解决此问题

    ============================================================

    解决办法二:

    sudo apt-get install libexpat1-dev 

    问题成功解决

     

     

     

     

     

     

    展开全文
  • 编译dbus 时出现: 1checking for accept4... yes checking abstract socket namespace... no checking for pkg-config... (cached) /usr/local/bin/pkg-config checking pkg-config is at least version 0.9.0....
    编译dbus 时出现:
    

    1checking for accept4... yes
    checking abstract socket namespace... no
    checking for pkg-config... (cached) /usr/local/bin/pkg-config
    checking pkg-config is at least version 0.9.0... yes
    checking for XML_ParserCreate_MM in -lexpat... no
    configure: error: Could not find expat.h, check config.log for failed attempts

    解决方案:

    export LDFLAGS=-Wl,-L/usr/local/lib,-lexpat
    export CPPFLAGS=-I/usr/local/include


    展开全文
  • buildroot 交叉编译DBUS

    2019-10-22 14:34:07
    dbus 依赖库:libmount 找不到: checking libelf.h usability... no checking libelf.h presence... no checking for libelf.h... no checking for LIBMOUNT... no configure: error: *** Could not find libmount...
  • linux 交叉编译dbus,expat

    千次阅读 2020-02-17 14:30:00
    dbus交叉编译 本文使用的交叉编译器::arm-himix200-linux 1.expat库 expat-2.2.9.tar.bz2 ./configure --without-tests --without-examples \ --prefix=/opt/hisi-linux/x86-arm/lib/expat \ --host=arm-himix200-...
  • 交叉编译DBUS

    千次阅读 2014-10-22 14:22:27
    4. 安装pkg-config (只能是0.9版, 系统debian4是0.21版, 不然dbus编译不过) 为glib做准备. apt-get install pkg-config   5. 解决安装glib的编译错误  stack pointer 问题:  echo ac_cv_type_long_long...
  • 交叉编译dbus文章汇总

    2014-11-18 11:21:44
    预安装vmware6.0, debian4.0 linux OS 配置IP, samba, telnet等网络服务 安装包命令: ./configure CC=arm-unknown-linux-gnu-gcc --prefix=/home/qudc/nfs --host=arm-linux --cache-file=...指定交叉编译工具
  • 这个python库,需要-ldbus-glib-1 -ldbus-1 -...所以,需要提前跨平台编译好这几个链接库。 ---- ./configure --host=arm-linux-gnueabihf --prefix=/hello/dbus-python-1.2.4/build_arm PYTHON_INCLUDES=-I/us
  • 由于用qt来检测U盘插拔,要用dbus。pc调试通过后,发现到板子里没有dbus。原来默认情况下,编译arm版本qt时是不带dbus的,因此要重新交叉编译qt。 我的配置: ./configure -prefix /usr/local/arm/arm2-qt-4.8.1 -op

空空如也

空空如也

1 2 3 4 5 ... 20
收藏数 6,744
精华内容 2,697
热门标签
关键字:

编译dbus