DBU-如何设置包括路径
dbus - how to set include paths
在我的系统dbus标头上放置在 /usr/include/dbus-1.0/dbus/
中, dbus-arch-deps.h
是其他位置(似乎很奇怪):我程序中的 /usr/lib/x86_64-linux-gnu/dbus-1.0/include/dbus/dbus-arch-deps.h
我包括 #include<dbus-1.0/dbus/dbus.h>
这样:#include<dbus/xxx.h>
我可以将dbus-arch-deps.h
复制到/usr/include/dbus-1.0/dbus/
,但是如何修复DBUS标题中的路径?
您的系统可能已安装了PKG-Config。
g++ $(pkg-config --cflags dbus-1) main.c
pkgconfig包含一个链接器/编译器/等的数据库。使用特定库所需的标志。有关更多信息,请参见man pkg-config
。
首先,您需要正确安装和配置它。您应该尝试以下命令:
sudo apt-get -y install dbus libdbus-1-dev libdbus-glib-1-2 libdbus-glib-1-dev
现在,这是您应该为编译编写的Makefile:
all:
g++ dbus.cpp -I/usr/include/dbus-1.0
-I/usr/lib/x86_64-linux-gnu/dbus-1.0/include
-I/usr/include/glib-2.0
-I/usr/lib/x86_64-linux-gnu/glib-2.0/include/
-ldbus-1
-ldbus-glib-1
现在,您可以包含诸如dbus/dbus.h,dbus/dbus-glib.h等的文件。
您不需要复制文件。
使用I
标志编译时,只需添加dbus
所在的路径:
示例:
g++ -Wall -I /usr/include/dbus-1.0/ -o main.o
使用DBUS所在的位置(在/usr/include
的标准位置中,您可以在源代码中引用以下文件:
#include <dbus/xxx.h>
同样,如果您必须针对dbus
链接,则必须将该路径附加到库中的路径,包括这样的路径:
g++ -Wall -I /usr/include/dbus-1.0/ -o main.o -L <dbus library path>
dbus library path is where the libraries of
dbus'Live。要弄清楚这一点,请咨询网络或搜索您的系统。
更新:
在QT-CREATOR中实现这一目标(我从未使用过),也许以下可以有所帮助:
如何在QT创建者中添加路径?
- VS Code C++:不准确的系统包括路径错误(wchar.h,boost/lambda/lambda.hpp)
- 包括没有完整路径的我的库
- 包括 VS Code 上的完整文件路径
- 在路径的独立Qt项目中包括外部库
- 定义相对包括路径
- cmake:包括vs vs add_subDirectory:相对标头文件路径
- C++范围 TS 包括实验路径
- C++包括断开的相对路径
- 包括不排除静态库项目的用户路径的路径
- 如何指定远程预处理器包括192.0.2.17://usr/include的路径
- Visual Studio 2010 包括目录路径
- DBU-如何设置包括路径
- 提升:在Windows中包括路径
- 包括路径目录
- C或C++或WinApi中是否有任何功能来创建目录,包括指定路径中所有不存在的目录
- 问题包括来自不同目录的头文件[不是路径问题]
- 当路径不包括路径或驱动器号时,文件放置在哪里
- 包括c++visual studio 2010中带有#ifdef的附加库路径
- 使用不在根项目目录上的源文件(包括在搜索路径中的文件)时发生链接错误(Visual C++)
- 有关窗口中的路径以及包括 Visual Studio 中的文件的说明