当我编译包含libechonest的c ++文件时,我在连接QtCore和QtNetwork库时遇到问题。具体做法是:
alexcannon$ gcc -g -Wall -o geoEchoNest geoEchoNest.cc -lechonest -lQtCore -lQtNetwork
In file included from geoEchoNest.c:6:
In file included from /usr/local/include/echonest/Artist.h:22:
In file included from /usr/local/include/echonest/ArtistTypes.h:21:
/usr/local/include/echonest/Util.h:22:10: fatal error: 'QDebug' file not found
#include <QDebug>
^
1 error generated.
我甚至尝试添加-L/usr/local/lib/QtCore.framework/
以防QtCore不在“标准路径”中(无论这意味着什么):
alexcannon$ gcc -g -Wall -o geoEchoNest geoEchoNest.cc -lechonest - L/usr/local/lib/QtCore.framework/ -lQtCore -lQtNetwork
......结果相同。我在这做错了什么?我通过README中的说明在安装libechonest之前在/ usr / local /以及QJSON中安装了Qt:
alexcannon$ cat README libechonest =========== libechonest is a collection of C++/Qt classes designed to make a developer's life easy when trying to use the APIs provided by The Echo Nest. More information about the APIs can be found here: http://developer.echonest.com/docs/v4/ libechonest is developed by Leo Franchi (lfranchi@kde.org), and is available at KDE's projects page, https://projects.kde.org/projects/playground/libs/libechonest . Review request are accepted at http://git.reviewboard.kde.org under the compenent libechonest, and API comments, and more are appreciated. Dependencies ============ * Qt, only the QtCore, QtNetwork and QtTest modules (www.qtsoftware.com) * CMake, Kitware's open source build system (http://cmake.org) * QJson (http://qjson.sourceforge.net/). Installing ========== mkdir build cd build cmake -DCMAKE_INSTALL_PREFIX=/path/to/desired/install .. make make install Using libechonest =============== The c++ API is meant to be as close to the Echo Nest API as possible. All Echo Nest API functions have been copied into their respective c++ equivalents, and string values converted to enums where reasonable. See the unit tests in tests/ for examples on how to use the classes. You need an API key from http://developer.echonest.com to use this library. Set your API key with Echonest::Config::instance()->setAPIKey(). You can also set your own custom QNetworkAccessManager-derived class with Config::setNetworkAccessManager(); Your link line needs to include the following: -lechonest -lQtCore -lQtNetwork Thank you for tuning in! leo ------- This README, and libechonest in general, is inspired by Max Howell's liblastfm, at http://www.github.com/mxcl/liblastfm.
提前感谢您的帮助!
答案 0 :(得分:0)
添加QtCore,QtNetwork和libechonest的标头。您只为链接器添加了库(-L
和-l
(小写L)),但您错过了添加标题(使用-I
(大写i))。