lordqwerty
lordqwerty

Reputation: 173

"undefined symbols for architecture" linker error when compiling a Qt tutorial

I am getting an error when trying to compile my QT app on Mac. I followed this tutorial all the code is at the bottom of the page.

When I build the project I get the following:

Undefined symbols for architecture x86_64:
  "DiagramItem::addArrow(Arrow*)", referenced from:
      DiagramScene::mouseReleaseEvent(QGraphicsSceneMouseEvent*) in diagramscene.o
  "DiagramScene::setItemType(DiagramItem::DiagramType)", referenced from:
      MainWindow::buttonGroupClicked(int) in mainwindow.o
      DiagramScene::qt_static_metacall(QObject*, QMetaObject::Call, int, void**) in moc_diagramscene.o
  "DiagramScene::setTextColor(QColor const&)", referenced from:
      MainWindow::textButtonTriggered() in mainwindow.o
  "DiagramScene::setMode(DiagramScene::Mode)", referenced from:
      MainWindow::buttonGroupClicked(int) in mainwindow.o
      MainWindow::pointerGroupClicked(int) in mainwindow.o
      MainWindow::itemInserted(DiagramItem*) in mainwindow.o
      MainWindow::textInserted(QGraphicsTextItem&) in mainwindow.o
      DiagramScene::qt_static_metacall(QObject*, QMetaObject::Call, int, void**) in moc_diagramscene.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: *** [DiagramScene.app/Contents/MacOS/DiagramScene] Error 1
18:41:52: The process "/usr/bin/make" exited with code 2.
Error while building/deploying project DiagramScene (kit: Desktop)
When executing step 'Make'

Anyone seen this before or any suggestions?

Thanks in advance. :)

Upvotes: 2

Views: 1164

Answers (1)

The linker is telling you exactly what's happening. There are no implementations provided for the methods that are listed, namely for:

  • DiagramItem::addArrow(Arrow*)
  • DiagramScene::setItemType(DiagramItem::DiagramType)
  • DiagramScene::setTextColor(QColor const&)
  • DiagramScene::setMode(DiagramScene::Mode)

Simply write the implementations of those methods. The example might be incomplete if you were copy-pasting the code from the help page.

Upvotes: 2

Related Questions