【问题标题】:dbus-1.0/dbus/dbus.h:29:10: fatal error: 'dbus/dbus-arch-deps.h' file not founddbus-1.0/dbus/dbus.h:29:10:致命错误:找不到“dbus/dbus-arch-deps.h”文件
【发布时间】:2019-10-14 16:59:38
【问题描述】:

我在我的程序中使用 dbus,但是当我包含 #include <dbus-1.0/dbus/dbus.h> 我收到错误: dbus-1.0/dbus/dbus.h:29:10: fatal error: 'dbus/dbus-arch-deps.h' file not found

dbus 文件夹中没有dbus-arch-deps.h 文件。

我可以在lib64/dbus-1.0/include/dbus/dbus-arch-deps.h文件夹中看到这个文件

谁能帮我编译一下? 或者任何建议,因为我被困在这里了。

【问题讨论】:

  • 最后我通过在 cflags 中添加 -I/usr/lib64/dbus-1.0/include/ 解决了这个问题。

标签: dbus google-chrome-os


【解决方案1】:

由于我没有得到任何人的答案,但我终于解决了这个问题。 如果有人遇到类似问题,所以想发布解决方案。

我通过在 cflags 中添加 -I/usr/lib64/dbus-1.0/include/ 解决了这个问题。

【讨论】:

  • 更好的解决方案是使用以下代码进行编译:$CC dbus-example.c $(pkg-config --libs --cflags dbus-1)
【解决方案2】:

迟到的答案。但是,这可能对使用 ubuntu(18.04 lts)在 WSL(Windows 子系统)上工作的人有所帮助。

包含的文件夹是

  • /usr/lib/x86_64-linux-gnu/dbus-1.0/include
  • /usr/include/dbus-1.0

还链接:

  • -ldbus-1

如果您在其中找不到任何内容,请尝试:sudo apt-get install dbus-x11

【讨论】:

    【解决方案3】:

    问题是 dbus 需要两个不同的包含路径。无论如何,最好的方法是在这里使用 pkg-config。实际上,pkg-config 文件 dbus-1.pc 包括这些 cflags:

    Cflags: -I${includedir}/dbus-1.0 -I${libdir}/dbus-1.0/include
    

    因此,以 Manjaro 为例,您会得到:

    pkg-config --cflags dbus-1
    -I/usr/include/dbus-1.0 -I/usr/lib/dbus-1.0/include
    

    在 arm debian 上你会得到:

    pkg-config --cflags dbus-1
    -I/usr/include/dbus-1.0 -I/usr/lib/arm-linux-gnueabihf/dbus-1.0/include
    

    【讨论】:

      【解决方案4】:

      正如here 已回答,如果您使用的是 CMake,只需添加

      target_include_directories(ProjectName PRIVATE /usr/lib/x86_64-linux-gnu/dbus-1.0/include/ /usr/include/dbus-1.0/)
      target_link_libraries(ProjectName PRIVATE dbus-1)
      

      add_executable 行之后的行,其中 ProjectName - 是您的项目的名称

      【讨论】:

        【解决方案5】:

        试试

        sudo cp /usr/lib/x86_64-linux-gnu/dbus-1.0/include/dbus/dbus-arch-deps.h /usr/include/dbus-1.0/dbus/.
        

        【讨论】:

          猜你喜欢
          • 2012-11-29
          • 2020-07-31
          • 2011-12-18
          • 1970-01-01
          • 2014-02-07
          • 2011-09-23
          • 1970-01-01
          • 2016-07-10
          • 2021-11-25
          相关资源
          最近更新 更多