Я совершенно новый для CMake, и я пытаюсь использовать его для создания небольшого приложения KDE. Я использовать модуль QtXml, моя программа не компилируется без проблем, но во время стадии компоновки, л.д. не найти компоненты QXml ...Ошибка CMake при связывании
main.cpp
#include "test.h"
int main(int argc, char **argv)
{
return 0;
}
test.h
#ifndef TEST_H
#define TEST_H
#include <QXmlResultItems>
#include <QString>
#include <QBuffer>
#include <QXmlQuery>
class test {
public:
test(){}
~test(){}
QXmlResultItems* find (const QString& node, const QString& xpath);
private:
QBuffer device_;
};
#endif // TEST_H
test.cpp
#include "test.h"
QXmlResultItems* test::find (const QString& node, const QString& xpath)
{
QXmlResultItems* result = new QXmlResultItems;
QXmlQuery query;
query.bindVariable ("device",&device_);
query.setQuery ("doc($device)/"+node+"/"+xpath);
query.evaluateTo (result);
return result;
}
CMakeLists.cmake
project(qtcmakepb)
find_package(KDE4 REQUIRED)
include (KDE4Defaults)
include_directories(${KDE4_INCLUDES} ${QT_INCLUDES})
#Supposed to be useless because of KDE4 REQUIRED and ${QT_INCLUDES}
find_package(Qt4 COMPONENTS QtCore QtXml REQUIRED)
# In this CMakeLists.txt we define which files
# are used to compile the application
set(qtcmakepb_SRCS main.cpp test.cpp)
# Set the name of the application
kde4_add_executable(qtcmakepb ${qtcmakepb_SRCS})
# Select which libraries we need to link to
target_link_libraries(qtcmakepb ${KDE4_KDEUI_LIBS})
target_link_libraries(qtcmakepb ${QT_QTCORE_LIBS})
target_link_libraries(qtcmakepb ${QT_QTXML_LIBS})
# Tell cmake to install the application binary
install(TARGETS qtcmakepb ${INSTALL_TARGETS_DEFAULT_ARGS})
# Install the .desktop file
install(PROGRAMS qtcmakepb.desktop DESTINATION ${XDG_APPS_INSTALL_DIR})
выход для макияжа:
Linking CXX executable qtcmakepb
CMakeFiles/qtcmakepb.dir/test.o: In function `test::find(QString const&, QString const&)':
/home/zelwina/projects/QtCmakePb/src/test.cpp:5: undefined reference to `QXmlResultItems::QXmlResultItems()'
/home/zelwina/projects/QtCmakePb/src/test.cpp:6: undefined reference to `QXmlQuery::QXmlQuery()'
/home/zelwina/projects/QtCmakePb/src/test.cpp:7: undefined reference to `QXmlQuery::bindVariable(QString const&, QIODevice*)'
/home/zelwina/projects/QtCmakePb/src/test.cpp:8: undefined reference to `QXmlQuery::setQuery(QString const&, QUrl const&)'
/home/zelwina/projects/QtCmakePb/src/test.cpp:9: undefined reference to `QXmlQuery::evaluateTo(QXmlResultItems*) const'
/home/zelwina/projects/QtCmakePb/src/test.cpp:10: undefined reference to `QXmlQuery::~QXmlQuery()'
collect2: erreur: ld a retourné 1 code d'état d'exécution
make[2]: *** [src/qtcmakepb] Erreur 1
make[1]: *** [src/CMakeFiles/qtcmakepb.dir/all] Erreur 2
make: *** [all] Erreur 2
Что я делаю неправильно?
Addind SET (QT_USE_QTXML ИСТИНА) не работает либо – Zelwina