c++ PackageKit newb链接问题

C++ PackageKit newb linking issue

本文关键字:问题 链接 newb PackageKit c++      更新时间:2023-10-16

我正试图将PackageKit导入到我正在使用的c++项目中(作为一个来自Java背景的c++新手)。我的目标是用我在系统上安装的包做一些事情。

我已经安装了libpackagekit-glib2-16, libpackagekit-glib2-dev, libpackagekit-qt2-6, libpackagekit-qt2-devpackagekit(我知道我不需要所有这些,但我现在只是覆盖我的基础)。我可以看到它们已经安装在这里:/usr/include/PackageKit,它有packagekit-glib2, packagekit-qt2, plugin子文件夹。

为了帮助我,我正在使用qt 5.2.1作为我的Makefiles拐杖,而我还在学习,但我现在并没有实际使用任何qt资源。我已经能够通过-lapt-lib-ldpkg在qt的LIBS+=下导入apt和dpkg的库,但我不知道如何导入packagekit的库(我尝试过多种变体,但我不知道如何正确导入此库)。

:

#define I_KNOW_THE_PACKAGEKIT_GLIB2_API_IS_SUBJECT_TO_CHANGE
#include <PackageKit/packagekit-glib2/packagekit.h>
int main(int argc, char *argv[])
{
    return 0;
}

结果如下:

g++ -c -std=c++11 -g -Wall -W -D_REENTRANT -fPIE -DQT_QML_DEBUG -DQT_DECLARATIVE_DEBUG -DQT_CORE_LIB -I/usr/lib/x86_64-linux-gnu/qt5/mkspecs/linux-g++-64 -I../console-example -I/usr/include/qt5 -I/usr/include/qt5/QtCore -I. -I. -o main.o ../console-example/main.cpp
In file included from ../console-example/main.cpp:3:0:
/usr/include/PackageKit/packagekit-glib2/packagekit.h:31:41: fatal error: packagekit-glib2/pk-catalog.h: No such file or directory
 #include <packagekit-glib2/pk-catalog.h>

如果这是必要的,我的系统是Ubuntu 14.04 64bit,正如我提到的,我使用qt 5.2.1来帮助制作文件。提前感谢大家!

这似乎是一个编译问题。编译器找不到packagekit的头文件。我想在g++行中你需要添加-I/usr/include/PackageKit或类似的东西。

从我的qt项目的.pro文件中,我不得不做以下补充,以获得它的编译和链接。

CONFIG += link_pkgconfig # This enables the next line
PKGCONFIG = gtk+-2.0     # This will link against gtk+-2.0
INCLUDEPATH += /usr/include/PackageKit/   # This is the include for packagekit
    += /usr/lib/glib-2.0/include/          # This will include glib, which packagekit is dependent on