I am using libvcard in a Qt Application. I installed the library on Ubuntu as instructed in the read me file (i.e. I ran qmake, make, sudo make install on the project file) but when I try to run this code from the website, I get a bunch of errors.
#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;
}
}
}
Errors
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) constvCard::property(QString const&, QList 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
‘
I’m not sure what I’ve done wrong.
Should I be adding something to the project file in order to use this library?
vcard is external library, so linker must know, where to look for used symbols. You need to link with vcard library. In your .pro file add