我一直在尝试为 dbus
编译一个程序正如我在代码中提到的类似问题所建议的那样。我确实执行了它,如图所示:
gcc `pkg-config --cflags dbus-glib-1` \
`pkg-config --cflags dbus-1` \
`pkg-config --cflags glib-2.0` \
dbus-example.c \
`pkg-config --libs dbus-glib-1` \
`pkg-config --libs dbus-1` \
`pkg-config --libs glib-2.0`
我仍然收到以下错误:
Package dbus-glib-1 was not found in the pkg-config search path.
Perhaps you should add the directory containing `dbus-glib-1.pc'
to the PKG_CONFIG_PATH environment variable
No package 'dbus-glib-1' found
Package glib-2.0 was not found in the pkg-config search path.
Perhaps you should add the directory containing `glib-2.0.pc'
to the PKG_CONFIG_PATH environment variable
No package 'glib-2.0' found
Package dbus-glib-1 was not found in the pkg-config search path.
Perhaps you should add the directory containing `dbus-glib-1.pc'
to the PKG_CONFIG_PATH environment variable
No package 'dbus-glib-1' found
Package glib-2.0 was not found in the pkg-config search path.
Perhaps you should add the directory containing `glib-2.0.pc'
to the PKG_CONFIG_PATH environment variable
No package 'glib-2.0' found
我安装了上面提到的软件包,但错误仍然存在。
最佳答案
您是否为这些库安装了开发包,或者只是库本身?在 Debian/Ubuntu 上,您需要 libdbus-glib-1-dev
和类似 -dev
其他人的包裹;在 Fedora 上,你想要 dbus-glib-devel
和类似的。
关于linker-errors - D-Bus 链接问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15239560/