Skip to content

Instantly share code, notes, and snippets.

@Superlokkus
Last active June 20, 2016 10:27
Show Gist options
  • Save Superlokkus/5aa16ab12a8a729864c04371587236d4 to your computer and use it in GitHub Desktop.
Save Superlokkus/5aa16ab12a8a729864c04371587236d4 to your computer and use it in GitHub Desktop.
Qt Quick /Find Qt4 cmake Linking Issue
/Applications/CLion.app/Contents/bin/cmake/bin/cmake --build /Users/markus/Library/Caches/CLion2016.1/cmake/generated/Prog2BelegMedienverwaltung-551c6070/551c6070/Debug --target Prog2Beleg -- -j 2
[ 25%] Automatic moc for target Prog2Beleg
[ 25%] Built target Prog2Beleg_automoc
[ 50%] Linking CXX executable Prog2Beleg
Undefined symbols for architecture x86_64:
"QDeclarativeEngine::QDeclarativeEngine(QObject*)", referenced from:
_main in main.cpp.o
"QDeclarativeEngine::~QDeclarativeEngine()", referenced from:
_main in main.cpp.o
"QDeclarativeContext::setContextProperty(QString const&, QObject*)", referenced from:
_main in main.cpp.o
"QDeclarativeContext::QDeclarativeContext(QDeclarativeContext*, QObject*)", referenced from:
_main in main.cpp.o
"QDeclarativeComponent::create(QDeclarativeContext*)", referenced from:
_main in main.cpp.o
"QDeclarativeComponent::setData(QByteArray const&, QUrl const&)", referenced from:
_main in main.cpp.o
"QDeclarativeComponent::QDeclarativeComponent(QDeclarativeEngine*, QObject*)", referenced from:
_main in main.cpp.o
"QDeclarativeComponent::~QDeclarativeComponent()", referenced from:
_main in main.cpp.o
"QDeclarativeEngine::rootContext() const", referenced from:
_main in main.cpp.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[3]: *** [Prog2Beleg] Error 1
make[2]: *** [CMakeFiles/Prog2Beleg.dir/all] Error 2
make[1]: *** [CMakeFiles/Prog2Beleg.dir/rule] Error 2
make: *** [Prog2Beleg] Error 2
cmake_minimum_required(VERSION 3.0)
project(Prog2Beleg)
set(CMAKE_AUTOMOC ON)
set(CMAKE_INCLUDE_CURRENT_DIR ON)
#Only on my OSX MBP13
#set(QTDIR "/opt/local/libexec/qt4" CACHE PATH "FOO" FORCE)
#set(QT_QMAKE_EXECUTABLE "/opt/local/libexec/qt4/bin/qmake" CACHE FILEPATH "BAR" FORCE)
find_package(Qt4 REQUIRED)
include_directories(${Qt_INCLUDE_DIR})
set(SOURCE_FILES main.cpp)
add_executable(Prog2Beleg ${SOURCE_FILES})
if(NOT(Qt4_FOUND))
target_link_libraries(Prog2Beleg Qt5::Widgets)
else()
target_link_libraries(Prog2Beleg Qt4::QtCore Qt4::QtGui)
endif()
set_property(TARGET Prog2Beleg PROPERTY LINKER_LANGUAGE CXX)
set_property(TARGET Prog2Beleg PROPERTY CXX_STANDARD 11)
#include <iostream>
#include <QtDeclarative/QDeclarativeContext>
#include <QtDeclarative/QDeclarativeEngine>
#include <QtDeclarative/QtDeclarative>
int main() {
QDeclarativeEngine engine;
QStringListModel modelData;
QDeclarativeContext *context = new QDeclarativeContext(engine.rootContext());
context->setContextProperty("myModel", &modelData);
QDeclarativeComponent component(&engine);
component.setData("import QtQuick 1.0\n ListView { model: myModel }", QUrl());
QObject *window = component.create(context);
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment