gpt4 book ai didi

ubuntu - 尝试在 Qt 应用程序中包含 libvcard 时出错

转载 作者:行者123 更新时间:2023-12-04 18:30:52 25 4
gpt4 key购买 nike

我正在使用 libvcard在 Qt 应用程序中。我按照自述文件中的说明在 Ubuntu 上安装了库(即,我在项目文件上运行了 qmakemakesudo make install),但是当我尝试从网站运行此代码时,我得到了一堆错误。

   #include <QtCore/QCoreApplication>
#include <vcard/vcard.h>
#include <QtDebug>

int main(int argc, char *argv[])
{
// Now we can parse it...
QList<vCard> vcards = vCard::fromFile("/home/ubuntu/Desktop/Contacts.vcf");

// ...and then we can use it.
if (!vcards.isEmpty())
{
vCard vcard = vcards.takeFirst();

vCardProperty name_prop = vcard.property(VC_NAME);
if (name_prop.isValid())
{
QStringList values = name_prop.values();

QString firstname = values.at(vCardProperty::Firstname);
QString lastname = values.at(vCardProperty::Lastname);

qDebug()<<firstname<<" "<<lastname;
}

}

}

错误

In function main:

/home/ubuntu/Workspace/Qt/cVCardTest-build-desktop-Desktop_Qt_4_8_1_for_GCC__Qt_SDK__Debug/../cVCardTest/main.cpp:8:

error: undefined reference to `vCard::fromFile(QString const&) /home/ubuntu/Workspace/Qt/cVCardTest-build-desktop-Desktop_Qt_4_8_1_for_GCC__Qt_SDK__Debug/../cVCardTest/main.cpp:15:

error: undefined reference to vCard::property(QString const&, QList<vCardParam> const&, bool) const
/home/ubuntu/Workspace/Qt/cVCardTest-build-desktop-Desktop_Qt_4_8_1_for_GCC__Qt_SDK__Debug/../cVCardTest/main.cpp:15: error: undefined reference to
vCard::property(QString const&, QList const&, bool) const' '



我不确定我做错了什么。
我应该在项目文件中添加一些东西以使用这个库吗?

最佳答案

vcard 是外部库,因此链接器必须知道在哪里查找使用过的符号。您需要与 vcard 库链接。在您的 .pro 文件中添加

LIBS += vcard

关于ubuntu - 尝试在 Qt 应用程序中包含 libvcard 时出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10996913/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com