dbus/dbus.h no such file or directory when building to arm

15,533

As far as I can see, you have wrong include directory for dbus. You have include_directories(/usr/include/dbus) and in my host Linux I have following include flags, if I issue pkg-config --cflags dbus-glib-1:

-pthread -I/usr/include/dbus-1.0 -I/usr/lib64/dbus-1.0/include -I/usr/include/glib-2.0 -I/usr/lib64/glib-2.0/include

Try to configure this include:

include_directories(/usr/include/dbus-1.0)
Share:
15,533
user1796260
Author by

user1796260

Updated on August 21, 2022

Comments

  • user1796260
    user1796260 over 1 year

    I'm trying to cross compile my project to arm to use it on a raspberry pi but it can't find dbus. Which was easily find when I was compiling classically. I'm using cmake I've added dbus-1 to target link library and I'm using arm-linux-gnueabihf to cross compile.

    Any idea?

    EDIT: add my CMakeLists.txt :

    set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/")
    
    FIND_PACKAGE(glib2) # bluetooth
    include_directories(${GLIB2_INCLUDE_DIRS}) # bluetooth
    
    include_directories(${CMAKE_SOURCE_DIR}/../bluez/gdbus)
    include_directories(${CMAKE_SOURCE_DIR}/../bluez/attrib)
    include_directories(${CMAKE_SOURCE_DIR}/../bluez/src)
    include_directories(${CMAKE_SOURCE_DIR}/../bluez/src/shared)
    include_directories(${CMAKE_SOURCE_DIR}/../bluez/btio)
    include_directories(${CMAKE_SOURCE_DIR}/../bluez/lib)
    include_directories(${CMAKE_SOURCE_DIR}/../bluez/client)
    include_directories(${CMAKE_SOURCE_DIR}/../bluez/emulator)
    include_directories(${CMAKE_SOURCE_DIR}/../bluez/monitor)
    include_directories(${CMAKE_SOURCE_DIR}/../bluez)
    include_directories(/usr/include/dbus)
    set( CMAKE_CXX_FLAGS "-fpermissive" )
    # Search every source files
    aux_source_directory(. SRC_LIST)
    
    include_directories (/usr)
    aux_source_directory(${CMAKE_SOURCE_DIR}/../bluez/gdbus SRC_BLUEZ_GDBUS)
    aux_source_directory(${CMAKE_SOURCE_DIR}/../bluez/client SRC_BLUEZ_CLIENT)
    aux_source_directory(${CMAKE_SOURCE_DIR}/../bluez/btio SRC_BLUEZ_BTIO_LIST)
    aux_source_directory(${CMAKE_SOURCE_DIR}/../bluez/attrib SRC_BLUEZ_ATTRIB_LIST)
    aux_source_directory(${CMAKE_SOURCE_DIR}/../bluez/emulator SRC_BLUEZ_EMULATOR)
    aux_source_directory(${CMAKE_SOURCE_DIR}/../bluez/lib SRC_BLUEZ_LIB)
    aux_source_directory(${CMAKE_SOURCE_DIR}/../bluez/monitor SRC_BLUEZ_MONITOR)
    aux_source_directory(${CMAKE_SOURCE_DIR}/../bluez/src SRC_BLUEZ_SRC)
    aux_source_directory(${CMAKE_SOURCE_DIR}/../bluez/src/shared SRC_BLUEZ_SRC_SHARED)
    
    
    add_executable(${PROJECT_NAME} ${SRC_LIST})
    
    # Library used in test
    add_library(${PROJECT_NAME}-lib 
                                    Thread.cpp
                                    NetworkThread.cpp 
                                    UdpSocket.cpp)
    add_library(MyBluezLib-lib
    ${SRC_BLUEZ_SRC} ${SRC_BLUEZ_LIB} 
        ${SRC_BLUEZ_GDBUS} ${SRC_BLUEZ_CLIENT} ${SRC_BLUEZ_BTIO_LIST} ${SRC_BLUEZ_ATTRIB_LIST} ${SRC_BLUEZ_EMULATOR} 
        ${SRC_BLUEZ_SRC_SHARED} ${SRC_BLUEZ_MONITOR})
    
    # Link libraries
    TARGET_LINK_LIBRARIES (${PROJECT_NAME} 
                            pthread 
                            glog
                            bluetooth
                            ${GLIB2_LIBRARIES} #bluetooth
                            readline
                            expat
                            dbus-1
                            dl
                            MyBluezLib-lib
                            )
    

    And this is my make call and his answear :

    Scanning dependencies of target MyBluezLib-lib
    [  1%] Building C object src/CMakeFiles/MyBluezLib-lib.dir/home/grosalex/job/stageING3/bluez/src/rfkill.c.obj
    In file included from /home/grosalex/job/stageING3/bluez/src/rfkill.c:39:0:
    /home/grosalex/job/stageING3/bluez/src/adapter.h:29:23: erreur fatale: dbus/dbus.h: Aucun fichier ou dossier de ce type
     #include <dbus/dbus.h>
    
                       ^
    

    compilation terminée.

  • user1796260
    user1796260 almost 10 years
    solve the problem but in my /usr/include the dbus folder is a link to dbus-1.0 so I don't understand why it was not working, is there any explanation? thanks a lot for the help
  • yegorich
    yegorich almost 10 years
    Have you tried include_directories(/usr/include/dbus/), i.e. add / after dbus?
  • user1796260
    user1796260 almost 10 years
    yes it doesn't work but include_directories(/usr/include/dbus-1.0) did but I just can't understant why?