Undefined reference when linking against custom library DLL
-
Given this open-source library using Qt components: https://github.com/simulton/qschematic
I am able to compile a DLL named
libqschematicd.dll
which I then link against in another Qt5 project (cmake based). However, during linking I am presented with errors like this:C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: CMakeFiles\qschematic-shared.dir/objects.a(connector.cpp.obj):connector.cpp:(.rdata$.refptr._ZN10QSchematic4Item16staticMetaObjectE[.refptr._ZN10QSchematic4Item16staticMetaObjectE]+0x0): undefined reference to `QSchematic::Item::staticMetaObject' C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: CMakeFiles\qschematic-shared.dir/objects.a(connector.cpp.obj):connector.cpp:(.rdata$.refptr._ZN10QSchematic4Item12movedInSceneERS0_[.refptr._ZN10QSchematic4Item12movedInSceneERS0_]+0x0): undefined reference to `QSchematic::Item::movedInScene(QSchematic::Item&)' C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: CMakeFiles\qschematic-shared.dir/objects.a(connector.cpp.obj):connector.cpp:(.rdata$.refptr._ZN10QSchematic4Item5movedERS0_RK9QVector2D[.refptr._ZN10QSchematic4Item5movedERS0_RK9QVector2D]+0x0): undefined reference to `QSchematic::Item::moved(QSchematic::Item&, QVector2D const&)' C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: CMakeFiles\qschematic-shared.dir/objects.a(connector.cpp.obj):connector.cpp:(.rdata$.refptr._ZTVN10QSchematic9ConnectorE[.refptr._ZTVN10QSchematic9ConnectorE]+0x0): undefined reference to `vtable for QSchematic::Connector' C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: CMakeFiles\qschematic-shared.dir/objects.a(item.cpp.obj): in function `QSchematic::Item::setSettings(QSchematic::Settings const&)': C:/Users/joel/Documents/projects/my_fancy_qt5_app/application/cmake-build-debug-mingw/_deps/qschematic-src/qschematic/items/item.cpp:226: undefined reference to `QSchematic::Item::settingsChanged()' C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: CMakeFiles\qschematic-shared.dir/objects.a(item.cpp.obj): in function `QSchematic::Item::posChanged()': C:/Users/joel/Documents/projects/my_fancy_qt5_app/application/cmake-build-debug-mingw/_deps/qschematic-src/qschematic/items/item.cpp:370: undefined reference to `QSchematic::Item::moved(QSchematic::Item&, QVector2D const&)' C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: CMakeFiles\qschematic-shared.dir/objects.a(item.cpp.obj): in function `QSchematic::Item::scenePosChanged()': C:/Users/joel/Documents/projects/my_fancy_qt5_app/application/cmake-build-debug-mingw/_deps/qschematic-src/qschematic/items/item.cpp:378: undefined reference to `QSchematic::Item::movedInScene(QSchematic::Item&)' C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: CMakeFiles\qschematic-shared.dir/objects.a(item.cpp.obj): in function `QSchematic::Item::rotChanged()': C:/Users/joel/Documents/projects/my_fancy_qt5_app/application/cmake-build-debug-mingw/_deps/qschematic-src/qschematic/items/item.cpp:386: undefined reference to `QSchematic::Item::rotated(QSchematic::Item&, double)' C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: CMakeFiles\qschematic-shared.dir/objects.a(item.cpp.obj):item.cpp:(.rdata$.refptr._ZN10QSchematic5Scene16staticMetaObjectE[.refptr._ZN10QSchematic5Scene16staticMetaObjectE]+0x0): undefined reference to `QSchematic::Scene::staticMetaObject' C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: CMakeFiles\qschematic-shared.dir/objects.a(item.cpp.obj):item.cpp:(.rdata$.refptr._ZN10QSchematic4Item7rotatedERS0_d[.refptr._ZN10QSchematic4Item7rotatedERS0_d]+0x0): undefined reference to `QSchematic::Item::rotated(QSchematic::Item&, double)' C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: CMakeFiles\qschematic-shared.dir/objects.a(item.cpp.obj):item.cpp:(.rdata$.refptr._ZTVN10QSchematic4ItemE[.refptr._ZTVN10QSchematic4ItemE]+0x0): undefined reference to `vtable for QSchematic::Item' C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: CMakeFiles\qschematic-shared.dir/objects.a(itemmimedata.cpp.obj):itemmimedata.cpp:(.rdata$.refptr._ZTVN10QSchematic12ItemMimeDataE[.refptr._ZTVN10QSchematic12ItemMimeDataE]+0x0): undefined reference to `vtable for QSchematic::ItemMimeData' C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: CMakeFiles\qschematic-shared.dir/objects.a(label.cpp.obj): in function `QSchematic::Label::setText(QString const&)': C:/Users/joel/Documents/projects/my_fancy_qt5_app/application/cmake-build-debug-mingw/_deps/qschematic-src/qschematic/items/label.cpp:97: undefined reference to `QSchematic::Label::textChanged(QString const&)' C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: CMakeFiles\qschematic-shared.dir/objects.a(label.cpp.obj): in function `QSchematic::Label::mouseDoubleClickEvent(QGraphicsSceneMouseEvent*)': C:/Users/joel/Documents/projects/my_fancy_qt5_app/application/cmake-build-debug-mingw/_deps/qschematic-src/qschematic/items/label.cpp:208: undefined reference to `QSchematic::Label::doubleClicked()' C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: CMakeFiles\qschematic-shared.dir/objects.a(label.cpp.obj):label.cpp:(.rdata$.refptr._ZTVN10QSchematic5LabelE[.refptr._ZTVN10QSchematic5LabelE]+0x0): undefined reference to `vtable for QSchematic::Label' C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: CMakeFiles\qschematic-shared.dir/objects.a(node.cpp.obj): in function `QSchematic::Node::setSize(QSizeF const&)': C:/Users/joel/Documents/projects/my_fancy_qt5_app/application/cmake-build-debug-mingw/_deps/qschematic-src/qschematic/items/node.cpp:186: undefined reference to `QSchematic::Node::sizeChanged()' C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: CMakeFiles\qschematic-shared.dir/objects.a(node.cpp.obj):node.cpp:(.rdata$.refptr._ZN10QSchematic4Item15settingsChangedEv[.refptr._ZN10QSchematic4Item15settingsChangedEv]+0x0): undefined reference to `QSchematic::Item::settingsChanged()' C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: CMakeFiles\qschematic-shared.dir/objects.a(node.cpp.obj):node.cpp:(.rdata$.refptr._ZTVN10QSchematic4NodeE[.refptr._ZTVN10QSchematic4NodeE]+0x0): undefined reference to `vtable for QSchematic::Node' C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: CMakeFiles\qschematic-shared.dir/objects.a(splinewire.cpp.obj):splinewire.cpp:(.rdata$.refptr._ZTVN10QSchematic10SplineWireE[.refptr._ZTVN10QSchematic10SplineWireE]+0x0): undefined reference to `vtable for QSchematic::SplineWire' C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: CMakeFiles\qschematic-shared.dir/objects.a(wire.cpp.obj): in function `QSchematic::Wire::prepend_point(QPointF const&)': C:/Users/joel/Documents/projects/my_fancy_qt5_app/application/cmake-build-debug-mingw/_deps/qschematic-src/qschematic/items/wire.cpp:227: undefined reference to `QSchematic::Wire::pointMoved(QSchematic::Wire&, wire_system::point&)' C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: CMakeFiles\qschematic-shared.dir/objects.a(wire.cpp.obj): in function `QSchematic::Wire::append_point(QPointF const&)': C:/Users/joel/Documents/projects/my_fancy_qt5_app/application/cmake-build-debug-mingw/_deps/qschematic-src/qschematic/items/wire.cpp:233: undefined reference to `QSchematic::Wire::pointMoved(QSchematic::Wire&, wire_system::point&)' C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: CMakeFiles\qschematic-shared.dir/objects.a(wire.cpp.obj): in function `QSchematic::Wire::insert_point(int, QPointF const&)': C:/Users/joel/Documents/projects/my_fancy_qt5_app/application/cmake-build-debug-mingw/_deps/qschematic-src/qschematic/items/wire.cpp:239: undefined reference to `QSchematic::Wire::pointMoved(QSchematic::Wire&, wire_system::point&)' C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: CMakeFiles\qschematic-shared.dir/objects.a(wire.cpp.obj): in function `QSchematic::Wire::move_point_to(int, QPointF const&)': C:/Users/joel/Documents/projects/my_fancy_qt5_app/application/cmake-build-debug-mingw/_deps/qschematic-src/qschematic/items/wire.cpp:268: undefined reference to `QSchematic::Wire::pointMoved(QSchematic::Wire&, wire_system::point&)' C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: CMakeFiles\qschematic-shared.dir/objects.a(wire.cpp.obj):wire.cpp:(.rdata$.refptr._ZN10QSchematic4Wire20toggleLabelRequestedEv[.refptr._ZN10QSchematic4Wire20toggleLabelRequestedEv]+0x0): undefined reference to `QSchematic::Wire::toggleLabelRequested()' C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: CMakeFiles\qschematic-shared.dir/objects.a(wire.cpp.obj):wire.cpp:(.rdata$.refptr._ZTVN10QSchematic4WireE[.refptr._ZTVN10QSchematic4WireE]+0x0): undefined reference to `vtable for QSchematic::Wire' C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: CMakeFiles\qschematic-shared.dir/objects.a(wirenet.cpp.obj):wirenet.cpp:(.rdata$.refptr._ZN10QSchematic4Wire16staticMetaObjectE[.refptr._ZN10QSchematic4Wire16staticMetaObjectE]+0x0): undefined reference to `QSchematic::Wire::staticMetaObject' C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: CMakeFiles\qschematic-shared.dir/objects.a(wirenet.cpp.obj):wirenet.cpp:(.rdata$.refptr._ZN10QSchematic5Label16staticMetaObjectE[.refptr._ZN10QSchematic5Label16staticMetaObjectE]+0x0): undefined reference to `QSchematic::Label::staticMetaObject' C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: CMakeFiles\qschematic-shared.dir/objects.a(wirenet.cpp.obj):wirenet.cpp:(.rdata$.refptr._ZN10QSchematic4Wire10pointMovedERS0_RN11wire_system5pointE[.refptr._ZN10QSchematic4Wire10pointMovedERS0_RN11wire_system5pointE]+0x0): undefined reference to `QSchematic::Wire::pointMoved(QSchematic::Wire&, wire_system::point&)' C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: CMakeFiles\qschematic-shared.dir/objects.a(wirenet.cpp.obj):wirenet.cpp:(.rdata$.refptr._ZN10QSchematic5Label13doubleClickedEv[.refptr._ZN10QSchematic5Label13doubleClickedEv]+0x0): undefined reference to `QSchematic::Label::doubleClicked()' C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: CMakeFiles\qschematic-shared.dir/objects.a(wirenet.cpp.obj):wirenet.cpp:(.rdata$.refptr._ZN10QSchematic4Item16highlightChangedERKS0_b[.refptr._ZN10QSchematic4Item16highlightChangedERKS0_b]+0x0): undefined reference to `QSchematic::Item::highlightChanged(QSchematic::Item const&, bool)' C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: CMakeFiles\qschematic-shared.dir/objects.a(wirenet.cpp.obj):wirenet.cpp:(.rdata$.refptr._ZTVN10QSchematic7WireNetE[.refptr._ZTVN10QSchematic7WireNetE]+0x0): undefined reference to `vtable for QSchematic::WireNet' C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: CMakeFiles\qschematic-shared.dir/objects.a(wireroundedcorners.cpp.obj):wireroundedcorners.cpp:(.rdata$.refptr._ZTVN10QSchematic18WireRoundedCornersE[.refptr._ZTVN10QSchematic18WireRoundedCornersE]+0x0): undefined reference to `vtable for QSchematic::WireRoundedCorners' C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: CMakeFiles\qschematic-shared.dir/objects.a(manager.cpp.obj): in function `wire_system::manager::point_moved_by_user(wire_system::wire&, int)': C:/Users/joel/Documents/projects/my_fancy_qt5_app/application/cmake-build-debug-mingw/_deps/qschematic-src/qschematic/wire_system/manager.cpp:248: undefined reference to `wire_system::manager::wire_point_moved(wire_system::wire&, int)' C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: CMakeFiles\qschematic-shared.dir/objects.a(manager.cpp.obj):manager.cpp:(.rdata$.refptr._ZTVN11wire_system7managerE[.refptr._ZTVN11wire_system7managerE]+0x0): undefined reference to `vtable for wire_system::manager' C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: CMakeFiles\qschematic-shared.dir/objects.a(scene.cpp.obj):C:/Users/joel/Documents/projects/my_fancy_qt5_app/application/cmake-build-debug-mingw/_deps/qschematic-src/qschematic/scene.cpp:43: undefined reference to `QSchematic::Scene::isDirtyChanged(bool)' C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: CMakeFiles\qschematic-shared.dir/objects.a(scene.cpp.obj): in function `QSchematic::Scene::setMode(int)': C:/Users/joel/Documents/projects/my_fancy_qt5_app/application/cmake-build-debug-mingw/_deps/qschematic-src/qschematic/scene.cpp:214: undefined reference to `QSchematic::Scene::modeChanged(int)' C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: CMakeFiles\qschematic-shared.dir/objects.a(scene.cpp.obj): in function `QSchematic::Scene::addItem(std::shared_ptr<QSchematic::Item> const&)': C:/Users/joel/Documents/projects/my_fancy_qt5_app/application/cmake-build-debug-mingw/_deps/qschematic-src/qschematic/scene.cpp:292: undefined reference to `QSchematic::Scene::itemAdded(std::shared_ptr<QSchematic::Item const>)' C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: CMakeFiles\qschematic-shared.dir/objects.a(scene.cpp.obj): in function `QSchematic::Scene::removeItem(std::shared_ptr<QSchematic::Item>)': C:/Users/joel/Documents/projects/my_fancy_qt5_app/application/cmake-build-debug-mingw/_deps/qschematic-src/qschematic/scene.cpp:320: undefined reference to `QSchematic::Scene::itemRemoved(std::shared_ptr<QSchematic::Item const>)' C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: CMakeFiles\qschematic-shared.dir/objects.a(scene.cpp.obj): in function `QSchematic::Scene::mouseMoveEvent(QGraphicsSceneMouseEvent*)': C:/Users/joel/Documents/projects/my_fancy_qt5_app/application/cmake-build-debug-mingw/_deps/qschematic-src/qschematic/scene.cpp:803: undefined reference to `QSchematic::Item::highlightChanged(QSchematic::Item const&, bool)' C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/Users/joel/Documents/projects/my_fancy_qt5_app/application/cmake-build-debug-mingw/_deps/qschematic-src/qschematic/scene.cpp:810: undefined reference to `QSchematic::Item::highlightChanged(QSchematic::Item const&, bool)' C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/Users/joel/Documents/projects/my_fancy_qt5_app/application/cmake-build-debug-mingw/_deps/qschematic-src/qschematic/scene.cpp:818: undefined reference to `QSchematic::Item::highlightChanged(QSchematic::Item const&, bool)' C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: CMakeFiles\qschematic-shared.dir/objects.a(scene.cpp.obj): in function `QSchematic::Scene::itemHoverEnter(std::shared_ptr<QSchematic::Item const> const&)': C:/Users/joel/Documents/projects/my_fancy_qt5_app/application/cmake-build-debug-mingw/_deps/qschematic-src/qschematic/scene.cpp:1121: undefined reference to `QSchematic::Scene::itemHighlighted(std::shared_ptr<QSchematic::Item const> const&)' C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: CMakeFiles\qschematic-shared.dir/objects.a(scene.cpp.obj): in function `QSchematic::Scene::itemHoverLeave(std::shared_ptr<QSchematic::Item const> const&)': C:/Users/joel/Documents/projects/my_fancy_qt5_app/application/cmake-build-debug-mingw/_deps/qschematic-src/qschematic/scene.cpp:1126: undefined reference to `QSchematic::Scene::itemHighlighted(std::shared_ptr<QSchematic::Item const> const&)' C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: CMakeFiles\qschematic-shared.dir/objects.a(scene.cpp.obj):scene.cpp:(.rdata$.refptr._ZN10QSchematic12ItemMimeData16staticMetaObjectE[.refptr._ZN10QSchematic12ItemMimeData16staticMetaObjectE]+0x0): undefined reference to `QSchematic::ItemMimeData::staticMetaObject' C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: CMakeFiles\qschematic-shared.dir/objects.a(scene.cpp.obj):scene.cpp:(.rdata$.refptr._ZN11wire_system7manager16staticMetaObjectE[.refptr._ZN11wire_system7manager16staticMetaObjectE]+0x0): undefined reference to `wire_system::manager::staticMetaObject' C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: CMakeFiles\qschematic-shared.dir/objects.a(scene.cpp.obj):scene.cpp:(.rdata$.refptr._ZN11wire_system7manager16wire_point_movedERNS_4wireEi[.refptr._ZN11wire_system7manager16wire_point_movedERNS_4wireEi]+0x0): undefined reference to `wire_system::manager::wire_point_moved(wire_system::wire&, int)' C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: CMakeFiles\qschematic-shared.dir/objects.a(scene.cpp.obj):scene.cpp:(.rdata$.refptr._ZTVN10QSchematic5SceneE[.refptr._ZTVN10QSchematic5SceneE]+0x0): undefined reference to `vtable for QSchematic::Scene' C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: CMakeFiles\qschematic-shared.dir/objects.a(view.cpp.obj): in function `QSchematic::View::updateScale()': C:/Users/joel/Documents/projects/my_fancy_qt5_app/application/cmake-build-debug-mingw/_deps/qschematic-src/qschematic/view.cpp:208: undefined reference to `QSchematic::View::zoomChanged(double)' C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: CMakeFiles\qschematic-shared.dir/objects.a(view.cpp.obj): in function `QSchematic::View::setMode(QSchematic::View::Mode)': C:/Users/joel/Documents/projects/my_fancy_qt5_app/application/cmake-build-debug-mingw/_deps/qschematic-src/qschematic/view.cpp:215: undefined reference to `QSchematic::View::modeChanged(QSchematic::View::Mode)' C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: CMakeFiles\qschematic-shared.dir/objects.a(view.cpp.obj):view.cpp:(.rdata$.refptr._ZN10QSchematic5Scene11modeChangedEi[.refptr._ZN10QSchematic5Scene11modeChangedEi]+0x0): undefined reference to `QSchematic::Scene::modeChanged(int)' C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: CMakeFiles\qschematic-shared.dir/objects.a(view.cpp.obj):view.cpp:(.rdata$.refptr._ZTVN10QSchematic4ViewE[.refptr._ZTVN10QSchematic4ViewE]+0x0): undefined reference to `vtable for QSchematic::View' collect2.exe: error: ld returned 1 exit status mingw32-make[3]: *** [_deps\qschematic-build\qschematic\CMakeFiles\qschematic-shared.dir\build.make:151: libqschematicd.dll] Error 1 mingw32-make[2]: *** [CMakeFiles\Makefile2:2281: _deps/qschematic-build/qschematic/CMakeFiles/qschematic-shared.dir/all] Error 2 mingw32-make[2]: *** Waiting for unfinished jobs....
Anything starting with the
QSchematic::
namespace are components provided by the QSchematic library which are exported into the DLL.From what I can tell there are mainly two types of undefined references reported:
- Qt internal stuff like
QSchematic::Node::qt_metacast(char const*)
- Signals provided by the library's components such as
QSchematic::Item::posChanged()
What needs to happen to make linking against this QSchematic library in a shared version work? Namely:
- Why are the various
qt_metacast()
functions missing? - Why are the signals missing?
I'd be thankful for any kind of information that would help me moving forward here.
Disclaimer: I am the author of that library.
- Qt internal stuff like
-
It looks like you added the sources from the qschematic lib to your own library/app which is wrong.
-
I think you're onto something here - I just found this in my application (which consumes the QSchematic lib) cmake script:
target_include_directories( ${TARGET} PRIVATE ${qschematic_SOURCE_DIR} # This needs fixing in the QSchematic library. This should not be necessary )
:-D
I'll investigate and report back!
-
It looks like you added the sources from the qschematic lib to your own library/app which is wrong.
@Christian-Ehrlicher I've fixed the include directories issue in the QSchematic library and removed the manual inclusion of the include dir in my application (the snipped posted above).
However, the issue remains:
[ 80%] Linking CXX shared library ..\..\..\libqschematicd.dll C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: CMakeFiles\qschematic-shared.dir/objects.a(connector.cpp.obj):connector.cpp:(.rdata$.refptr._ZN10QSchematic4Item16staticMetaObjectE[.refptr._ZN10QSchematic4Item16staticMetaObjectE]+0x0): undefined reference to `QSchematic::Item::staticMetaObject' C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: CMakeFiles\qschematic-shared.dir/objects.a(connector.cpp.obj):connector.cpp:(.rdata$.refptr._ZN10QSchematic4Item12movedInSceneERS0_[.refptr._ZN10QSchematic4Item12movedInSceneERS0_]+0x0): undefined reference to `QSchematic::Item::movedInScene(QSchematic::Item&)' C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: CMakeFiles\qschematic-shared.dir/objects.a(connector.cpp.obj):connector.cpp:(.rdata$.refptr._ZN10QSchematic4Item5movedERS0_RK9QVector2D[.refptr._ZN10QSchematic4Item5movedERS0_RK9QVector2D]+0x0): undefined reference to `QSchematic::Item::moved(QSchematic::Item&, QVector2D const&)' C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: CMakeFiles\qschematic-shared.dir/objects.a(connector.cpp.obj):connector.cpp:(.rdata$.refptr._ZTVN10QSchematic9ConnectorE[.refptr._ZTVN10QSchematic9ConnectorE]+0x0): undefined reference to `vtable for QSchematic::Connector' C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: CMakeFiles\qschematic-shared.dir/objects.a(item.cpp.obj): in function `QSchematic::Item::setSettings(QSchematic::Settings const&)': C:/Users/joel/Documents/projects/my_fancy_qt5_app/application/cmake-build-debug-mingw/_deps/qschematic-src/qschematic/items/item.cpp:226: undefined reference to `QSchematic::Item::settingsChanged()' C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: CMakeFiles\qschematic-shared.dir/objects.a(item.cpp.obj): in function `QSchematic::Item::posChanged()': C:/Users/joel/Documents/projects/my_fancy_qt5_app/application/cmake-build-debug-mingw/_deps/qschematic-src/qschematic/items/item.cpp:370: undefined reference to `QSchematic::Item::moved(QSchematic::Item&, QVector2D const&)' C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: CMakeFiles\qschematic-shared.dir/objects.a(item.cpp.obj): in function `QSchematic::Item::scenePosChanged()': C:/Users/joel/Documents/projects/my_fancy_qt5_app/application/cmake-build-debug-mingw/_deps/qschematic-src/qschematic/items/item.cpp:378: undefined reference to `QSchematic::Item::movedInScene(QSchematic::Item&)' C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: CMakeFiles\qschematic-shared.dir/objects.a(item.cpp.obj): in function `QSchematic::Item::rotChanged()': C:/Users/joel/Documents/projects/my_fancy_qt5_app/application/cmake-build-debug-mingw/_deps/qschematic-src/qschematic/items/item.cpp:386: undefined reference to `QSchematic::Item::rotated(QSchematic::Item&, double)' C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: CMakeFiles\qschematic-shared.dir/objects.a(item.cpp.obj):item.cpp:(.rdata$.refptr._ZN10QSchematic5Scene16staticMetaObjectE[.refptr._ZN10QSchematic5Scene16staticMetaObjectE]+0x0): undefined reference to `QSchematic::Scene::staticMetaObject' C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: CMakeFiles\qschematic-shared.dir/objects.a(item.cpp.obj):item.cpp:(.rdata$.refptr._ZN10QSchematic4Item7rotatedERS0_d[.refptr._ZN10QSchematic4Item7rotatedERS0_d]+0x0): undefined reference to `QSchematic::Item::rotated(QSchematic::Item&, double)' C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: CMakeFiles\qschematic-shared.dir/objects.a(item.cpp.obj):item.cpp:(.rdata$.refptr._ZTVN10QSchematic4ItemE[.refptr._ZTVN10QSchematic4ItemE]+0x0): undefined reference to `vtable for QSchematic::Item' C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: CMakeFiles\qschematic-shared.dir/objects.a(itemmimedata.cpp.obj):itemmimedata.cpp:(.rdata$.refptr._ZTVN10QSchematic12ItemMimeDataE[.refptr._ZTVN10QSchematic12ItemMimeDataE]+0x0): undefined reference to `vtable for QSchematic::ItemMimeData' C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: CMakeFiles\qschematic-shared.dir/objects.a(label.cpp.obj): in function `QSchematic::Label::setText(QString const&)': C:/Users/joel/Documents/projects/my_fancy_qt5_app/application/cmake-build-debug-mingw/_deps/qschematic-src/qschematic/items/label.cpp:97: undefined reference to `QSchematic::Label::textChanged(QString const&)' C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: CMakeFiles\qschematic-shared.dir/objects.a(label.cpp.obj): in function `QSchematic::Label::mouseDoubleClickEvent(QGraphicsSceneMouseEvent*)': C:/Users/joel/Documents/projects/my_fancy_qt5_app/application/cmake-build-debug-mingw/_deps/qschematic-src/qschematic/items/label.cpp:208: undefined reference to `QSchematic::Label::doubleClicked()' C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: CMakeFiles\qschematic-shared.dir/objects.a(label.cpp.obj):label.cpp:(.rdata$.refptr._ZTVN10QSchematic5LabelE[.refptr._ZTVN10QSchematic5LabelE]+0x0): undefined reference to `vtable for QSchematic::Label' C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: CMakeFiles\qschematic-shared.dir/objects.a(node.cpp.obj): in function `QSchematic::Node::setSize(QSizeF const&)': C:/Users/joel/Documents/projects/my_fancy_qt5_app/application/cmake-build-debug-mingw/_deps/qschematic-src/qschematic/items/node.cpp:186: undefined reference to `QSchematic::Node::sizeChanged()' C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: CMakeFiles\qschematic-shared.dir/objects.a(node.cpp.obj):node.cpp:(.rdata$.refptr._ZN10QSchematic4Item15settingsChangedEv[.refptr._ZN10QSchematic4Item15settingsChangedEv]+0x0): undefined reference to `QSchematic::Item::settingsChanged()' C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: CMakeFiles\qschematic-shared.dir/objects.a(node.cpp.obj):node.cpp:(.rdata$.refptr._ZTVN10QSchematic4NodeE[.refptr._ZTVN10QSchematic4NodeE]+0x0): undefined reference to `vtable for QSchematic::Node' C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: CMakeFiles\qschematic-shared.dir/objects.a(splinewire.cpp.obj):splinewire.cpp:(.rdata$.refptr._ZTVN10QSchematic10SplineWireE[.refptr._ZTVN10QSchematic10SplineWireE]+0x0): undefined reference to `vtable for QSchematic::SplineWire' C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: CMakeFiles\qschematic-shared.dir/objects.a(wire.cpp.obj): in function `QSchematic::Wire::prepend_point(QPointF const&)': C:/Users/joel/Documents/projects/my_fancy_qt5_app/application/cmake-build-debug-mingw/_deps/qschematic-src/qschematic/items/wire.cpp:227: undefined reference to `QSchematic::Wire::pointMoved(QSchematic::Wire&, wire_system::point&)' C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: CMakeFiles\qschematic-shared.dir/objects.a(wire.cpp.obj): in function `QSchematic::Wire::append_point(QPointF const&)': C:/Users/joel/Documents/projects/my_fancy_qt5_app/application/cmake-build-debug-mingw/_deps/qschematic-src/qschematic/items/wire.cpp:233: undefined reference to `QSchematic::Wire::pointMoved(QSchematic::Wire&, wire_system::point&)' C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: CMakeFiles\qschematic-shared.dir/objects.a(wire.cpp.obj): in function `QSchematic::Wire::insert_point(int, QPointF const&)': C:/Users/joel/Documents/projects/my_fancy_qt5_app/application/cmake-build-debug-mingw/_deps/qschematic-src/qschematic/items/wire.cpp:239: undefined reference to `QSchematic::Wire::pointMoved(QSchematic::Wire&, wire_system::point&)' C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: CMakeFiles\qschematic-shared.dir/objects.a(wire.cpp.obj): in function `QSchematic::Wire::move_point_to(int, QPointF const&)': C:/Users/joel/Documents/projects/my_fancy_qt5_app/application/cmake-build-debug-mingw/_deps/qschematic-src/qschematic/items/wire.cpp:268: undefined reference to `QSchematic::Wire::pointMoved(QSchematic::Wire&, wire_system::point&)' C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: CMakeFiles\qschematic-shared.dir/objects.a(wire.cpp.obj):wire.cpp:(.rdata$.refptr._ZN10QSchematic4Wire20toggleLabelRequestedEv[.refptr._ZN10QSchematic4Wire20toggleLabelRequestedEv]+0x0): undefined reference to `QSchematic::Wire::toggleLabelRequested()' C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: CMakeFiles\qschematic-shared.dir/objects.a(wire.cpp.obj):wire.cpp:(.rdata$.refptr._ZTVN10QSchematic4WireE[.refptr._ZTVN10QSchematic4WireE]+0x0): undefined reference to `vtable for QSchematic::Wire' C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: CMakeFiles\qschematic-shared.dir/objects.a(wirenet.cpp.obj):wirenet.cpp:(.rdata$.refptr._ZN10QSchematic4Wire16staticMetaObjectE[.refptr._ZN10QSchematic4Wire16staticMetaObjectE]+0x0): undefined reference to `QSchematic::Wire::staticMetaObject' C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: CMakeFiles\qschematic-shared.dir/objects.a(wirenet.cpp.obj):wirenet.cpp:(.rdata$.refptr._ZN10QSchematic5Label16staticMetaObjectE[.refptr._ZN10QSchematic5Label16staticMetaObjectE]+0x0): undefined reference to `QSchematic::Label::staticMetaObject' C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: CMakeFiles\qschematic-shared.dir/objects.a(wirenet.cpp.obj):wirenet.cpp:(.rdata$.refptr._ZN10QSchematic4Wire10pointMovedERS0_RN11wire_system5pointE[.refptr._ZN10QSchematic4Wire10pointMovedERS0_RN11wire_system5pointE]+0x0): undefined reference to `QSchematic::Wire::pointMoved(QSchematic::Wire&, wire_system::point&)' C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: CMakeFiles\qschematic-shared.dir/objects.a(wirenet.cpp.obj):wirenet.cpp:(.rdata$.refptr._ZN10QSchematic5Label13doubleClickedEv[.refptr._ZN10QSchematic5Label13doubleClickedEv]+0x0): undefined reference to `QSchematic::Label::doubleClicked()' C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: CMakeFiles\qschematic-shared.dir/objects.a(wirenet.cpp.obj):wirenet.cpp:(.rdata$.refptr._ZN10QSchematic4Item16highlightChangedERKS0_b[.refptr._ZN10QSchematic4Item16highlightChangedERKS0_b]+0x0): undefined reference to `QSchematic::Item::highlightChanged(QSchematic::Item const&, bool)' C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: CMakeFiles\qschematic-shared.dir/objects.a(wirenet.cpp.obj):wirenet.cpp:(.rdata$.refptr._ZTVN10QSchematic7WireNetE[.refptr._ZTVN10QSchematic7WireNetE]+0x0): undefined reference to `vtable for QSchematic::WireNet' C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: CMakeFiles\qschematic-shared.dir/objects.a(wireroundedcorners.cpp.obj):wireroundedcorners.cpp:(.rdata$.refptr._ZTVN10QSchematic18WireRoundedCornersE[.refptr._ZTVN10QSchematic18WireRoundedCornersE]+0x0): undefined reference to `vtable for QSchematic::WireRoundedCorners' C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: CMakeFiles\qschematic-shared.dir/objects.a(manager.cpp.obj): in function `wire_system::manager::point_moved_by_user(wire_system::wire&, int)': C:/Users/joel/Documents/projects/my_fancy_qt5_app/application/cmake-build-debug-mingw/_deps/qschematic-src/qschematic/wire_system/manager.cpp:248: undefined reference to `wire_system::manager::wire_point_moved(wire_system::wire&, int)' C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: CMakeFiles\qschematic-shared.dir/objects.a(manager.cpp.obj):manager.cpp:(.rdata$.refptr._ZTVN11wire_system7managerE[.refptr._ZTVN11wire_system7managerE]+0x0): undefined reference to `vtable for wire_system::manager' C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: CMakeFiles\qschematic-shared.dir/objects.a(scene.cpp.obj):C:/Users/joel/Documents/projects/my_fancy_qt5_app/application/cmake-build-debug-mingw/_deps/qschematic-src/qschematic/scene.cpp:43: undefined reference to `QSchematic::Scene::isDirtyChanged(bool)' C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: CMakeFiles\qschematic-shared.dir/objects.a(scene.cpp.obj): in function `QSchematic::Scene::setMode(int)': C:/Users/joel/Documents/projects/my_fancy_qt5_app/application/cmake-build-debug-mingw/_deps/qschematic-src/qschematic/scene.cpp:214: undefined reference to `QSchematic::Scene::modeChanged(int)' C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: CMakeFiles\qschematic-shared.dir/objects.a(scene.cpp.obj): in function `QSchematic::Scene::addItem(std::shared_ptr<QSchematic::Item> const&)': C:/Users/joel/Documents/projects/my_fancy_qt5_app/application/cmake-build-debug-mingw/_deps/qschematic-src/qschematic/scene.cpp:292: undefined reference to `QSchematic::Scene::itemAdded(std::shared_ptr<QSchematic::Item const>)' C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: CMakeFiles\qschematic-shared.dir/objects.a(scene.cpp.obj): in function `QSchematic::Scene::removeItem(std::shared_ptr<QSchematic::Item>)': C:/Users/joel/Documents/projects/my_fancy_qt5_app/application/cmake-build-debug-mingw/_deps/qschematic-src/qschematic/scene.cpp:320: undefined reference to `QSchematic::Scene::itemRemoved(std::shared_ptr<QSchematic::Item const>)' C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: CMakeFiles\qschematic-shared.dir/objects.a(scene.cpp.obj): in function `QSchematic::Scene::mouseMoveEvent(QGraphicsSceneMouseEvent*)': C:/Users/joel/Documents/projects/my_fancy_qt5_app/application/cmake-build-debug-mingw/_deps/qschematic-src/qschematic/scene.cpp:803: undefined reference to `QSchematic::Item::highlightChanged(QSchematic::Item const&, bool)' C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/Users/joel/Documents/projects/my_fancy_qt5_app/application/cmake-build-debug-mingw/_deps/qschematic-src/qschematic/scene.cpp:810: undefined reference to `QSchematic::Item::highlightChanged(QSchematic::Item const&, bool)' C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/Users/joel/Documents/projects/my_fancy_qt5_app/application/cmake-build-debug-mingw/_deps/qschematic-src/qschematic/scene.cpp:818: undefined reference to `QSchematic::Item::highlightChanged(QSchematic::Item const&, bool)' C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: CMakeFiles\qschematic-shared.dir/objects.a(scene.cpp.obj): in function `QSchematic::Scene::itemHoverEnter(std::shared_ptr<QSchematic::Item const> const&)': C:/Users/joel/Documents/projects/my_fancy_qt5_app/application/cmake-build-debug-mingw/_deps/qschematic-src/qschematic/scene.cpp:1121: undefined reference to `QSchematic::Scene::itemHighlighted(std::shared_ptr<QSchematic::Item const> const&)' C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: CMakeFiles\qschematic-shared.dir/objects.a(scene.cpp.obj): in function `QSchematic::Scene::itemHoverLeave(std::shared_ptr<QSchematic::Item const> const&)': C:/Users/joel/Documents/projects/my_fancy_qt5_app/application/cmake-build-debug-mingw/_deps/qschematic-src/qschematic/scene.cpp:1126: undefined reference to `QSchematic::Scene::itemHighlighted(std::shared_ptr<QSchematic::Item const> const&)' C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: CMakeFiles\qschematic-shared.dir/objects.a(scene.cpp.obj):scene.cpp:(.rdata$.refptr._ZN10QSchematic12ItemMimeData16staticMetaObjectE[.refptr._ZN10QSchematic12ItemMimeData16staticMetaObjectE]+0x0): undefined reference to `QSchematic::ItemMimeData::staticMetaObject' C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: CMakeFiles\qschematic-shared.dir/objects.a(scene.cpp.obj):scene.cpp:(.rdata$.refptr._ZN11wire_system7manager16staticMetaObjectE[.refptr._ZN11wire_system7manager16staticMetaObjectE]+0x0): undefined reference to `wire_system::manager::staticMetaObject' C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: CMakeFiles\qschematic-shared.dir/objects.a(scene.cpp.obj):scene.cpp:(.rdata$.refptr._ZN11wire_system7manager16wire_point_movedERNS_4wireEi[.refptr._ZN11wire_system7manager16wire_point_movedERNS_4wireEi]+0x0): undefined reference to `wire_system::manager::wire_point_moved(wire_system::wire&, int)' C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: CMakeFiles\qschematic-shared.dir/objects.a(scene.cpp.obj):scene.cpp:(.rdata$.refptr._ZTVN10QSchematic5SceneE[.refptr._ZTVN10QSchematic5SceneE]+0x0): undefined reference to `vtable for QSchematic::Scene' C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: CMakeFiles\qschematic-shared.dir/objects.a(view.cpp.obj): in function `QSchematic::View::updateScale()': C:/Users/joel/Documents/projects/my_fancy_qt5_app/application/cmake-build-debug-mingw/_deps/qschematic-src/qschematic/view.cpp:208: undefined reference to `QSchematic::View::zoomChanged(double)' C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: CMakeFiles\qschematic-shared.dir/objects.a(view.cpp.obj): in function `QSchematic::View::setMode(QSchematic::View::Mode)': C:/Users/joel/Documents/projects/my_fancy_qt5_app/application/cmake-build-debug-mingw/_deps/qschematic-src/qschematic/view.cpp:215: undefined reference to `QSchematic::View::modeChanged(QSchematic::View::Mode)' C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: CMakeFiles\qschematic-shared.dir/objects.a(view.cpp.obj):view.cpp:(.rdata$.refptr._ZN10QSchematic5Scene11modeChangedEi[.refptr._ZN10QSchematic5Scene11modeChangedEi]+0x0): undefined reference to `QSchematic::Scene::modeChanged(int)' C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: CMakeFiles\qschematic-shared.dir/objects.a(view.cpp.obj):view.cpp:(.rdata$.refptr._ZTVN10QSchematic4ViewE[.refptr._ZTVN10QSchematic4ViewE]+0x0): undefined reference to `vtable for QSchematic::View' collect2.exe: error: ld returned 1 exit status mingw32-make[3]: *** [_deps\qschematic-build\qschematic\CMakeFiles\qschematic-shared.dir\build.make:151: libqschematicd.dll] Error 1 mingw32-make[2]: *** [CMakeFiles\Makefile2:2281: _deps/qschematic-build/qschematic/CMakeFiles/qschematic-shared.dir/all] Error 2 mingw32-make[2]: *** Waiting for unfinished jobs....
As I understand now properly (thanks to your hint) the QSchematic shared library is compiled by my app/plugin as I pull it in via cmake's
FetchContent()
. The error is actually originating from compiling thelibqschematicd.dll
- not my app/plugin.I include the QSchematic library in my application/plugin using cmake's
FetchContent()
:# Fetch QSchematic library FetchContent_Declare( qschematic GIT_REPOSITORY https://github.com/simulton/qschematic GIT_TAG master ) FetchContent_GetProperties(qschematic) if(NOT qschematic_POPULATED) FetchContent_Populate(qschematic) set(QSCHEMATIC_BUILD_DEMO OFF CACHE INTERNAL "") set(QSCHEMATIC_DEPENDENCY_GPDS_DOWNLOAD OFF CACHE INTERNAL "") set(QSCHEMATIC_DEPENDENCY_GPDS_TARGET "gpds-shared" CACHE INTERNAL "") add_subdirectory(${qschematic_SOURCE_DIR} ${qschematic_BINARY_DIR}) endif() # Link to app/plugin target_link_libraries( my_app_or_plugin PRIVATE qschematic-shared )
However, compiling
libqschematicd.dll
directly from the QSchematic cmake script works well - what am I missing here? -
All of my work on Windows has been done with MSVC and not mingw, so I might be way off base... but it seems worth asking...
In the mingw environment, do windows DLL(s) still need to worry about
dllexport
?(link to MSDN content regarding dllexport)
If so, then you need a special header for every library, like so:
#ifndef MYHEADER_GUARD_H #define MYHEADER_GUARD_H #include <QtCore/qglobal.h> // be sure to REPLACE "LIBSTYLES" with YOUR library name #if defined( LIBSTYLES_LIBRARY ) # define LIBSTYLES_EXPORT Q_DECL_EXPORT #else # define LIBSTYLES_EXPORT Q_DECL_IMPORT #endif #endif // MYHEADER_GUARD_H
Then you have to annotate your classes, and also be sure to configure the preprocessor definition when you build
QSchematic
.Actually... looking at your GitHub repo, I see that you added the
QSCHEMATIC_EXPORT
yesterday. I'm digging through to see if maybe you missed a spot.... -
I see in your commit 830adbe97f07 that you added lines like
#include "qschematic_export.h"
but you did not commit a file namedqschematic_export.h
? Does CMake generate it somehow? (I useqmake
on most things and have minimal CMake fluency.)Anyhow, I will make a general statement about similar linker errors I have encountered in the past:
- If the symbols are missing (a.k.a. undefined) when you compile the library that should contain those very symbols, then one possibility is that your preprocessor IMPORT_EXPORT macro is getting set as
dllimport
during that build when it should be set todllexport
- If the symbols are missing when compiling other "user code" that depends on the library with the symbols, then (at a minimum) two possibilities exist: (a) the depended-upon library failed to tag its classes/functions with either
dllimport
ordllexport
(meaning you failed to tag them at all when compiling that DLL), or (b) the preprocessor and header situation is such thatdllexport
is being applied even by this dependent "user code", whereas in this case it needs to bedllimport
-ing the symbols from the depended-upon library.
- If the symbols are missing (a.k.a. undefined) when you compile the library that should contain those very symbols, then one possibility is that your preprocessor IMPORT_EXPORT macro is getting set as
-
All of my work on Windows has been done with MSVC and not mingw, so I might be way off base... but it seems worth asking...
In the mingw environment, do windows DLL(s) still need to worry about
dllexport
?(link to MSDN content regarding dllexport)
If so, then you need a special header for every library, like so:
#ifndef MYHEADER_GUARD_H #define MYHEADER_GUARD_H #include <QtCore/qglobal.h> // be sure to REPLACE "LIBSTYLES" with YOUR library name #if defined( LIBSTYLES_LIBRARY ) # define LIBSTYLES_EXPORT Q_DECL_EXPORT #else # define LIBSTYLES_EXPORT Q_DECL_IMPORT #endif #endif // MYHEADER_GUARD_H
Then you have to annotate your classes, and also be sure to configure the preprocessor definition when you build
QSchematic
.Actually... looking at your GitHub repo, I see that you added the
QSCHEMATIC_EXPORT
yesterday. I'm digging through to see if maybe you missed a spot....@KH-219Design said in Undefined reference when linking against custom library DLL:
In the mingw environment, do windows DLL(s) still need to worry about dllexport?
It works without but it's nice if the library works with MSVC too ;)
@KH-219Design said in Undefined reference when linking against custom library DLL:
I see in your commit 830adbe97f07 that you added lines like #include "qschematic_export.h" but you did not commit a file named qschematic_export.h? Does CMake generate it somehow? (I use qmake on most things and have minimal CMake fluency.)
Yes that's correct. It gets generated by cmake's
generate_export_header()
function. That part appears to work as expected.@KH-219Design said in Undefined reference when linking against custom library DLL:
Anyhow, I will make a general statement about similar linker errors I have encountered in the past:
That is certainly helpful information but unfortunately also things I checked before posting here. I also inspected the compiled DLL and that seemed fine on first glance. However, I'm not sure about the aforementioned signals.
In the meantime, I created a clean minimal cmake based application, added the QSchematic library via cmake's
FetchContent_Declare()
, linked the DLL into the app viatarget_link_libraries()
and the application linked and started fine.The difference between what I have shown in this post and that minimal application is that I'm building a DLL which gets loaded into a Qt application (not a Qt plugin - just a regular home-grown plugin that gets loaded into a Qt application using
QPluginLoader
). -
@KH-219Design said in Undefined reference when linking against custom library DLL:
In the mingw environment, do windows DLL(s) still need to worry about dllexport?
It works without but it's nice if the library works with MSVC too ;)
@KH-219Design said in Undefined reference when linking against custom library DLL:
I see in your commit 830adbe97f07 that you added lines like #include "qschematic_export.h" but you did not commit a file named qschematic_export.h? Does CMake generate it somehow? (I use qmake on most things and have minimal CMake fluency.)
Yes that's correct. It gets generated by cmake's
generate_export_header()
function. That part appears to work as expected.@KH-219Design said in Undefined reference when linking against custom library DLL:
Anyhow, I will make a general statement about similar linker errors I have encountered in the past:
That is certainly helpful information but unfortunately also things I checked before posting here. I also inspected the compiled DLL and that seemed fine on first glance. However, I'm not sure about the aforementioned signals.
In the meantime, I created a clean minimal cmake based application, added the QSchematic library via cmake's
FetchContent_Declare()
, linked the DLL into the app viatarget_link_libraries()
and the application linked and started fine.The difference between what I have shown in this post and that minimal application is that I'm building a DLL which gets loaded into a Qt application (not a Qt plugin - just a regular home-grown plugin that gets loaded into a Qt application using
QPluginLoader
).@Joel-Bodenmann said in Undefined reference when linking against custom library DLL:
It works without but it's nice if the library works with MSVC too ;)
Only if you don't export anything does mingw default to the *nix behaviour of exporting all the symbols. So either export all (which is what I recommend), or don't export anything.
@Joel-Bodenmann said in Undefined reference when linking against custom library DLL:
However, the issue remains:
It does look like the usual missing symbols. Make sure you're linking correctly against release/debug binary - on windows these are different libraries. Could you check if said symbols are really exported in the binary? I would imagine not ...
PS. I couldn't find your export header in the repository ... please don't tell me you're generating it on the fly ...
-
@Joel-Bodenmann said in Undefined reference when linking against custom library DLL:
It works without but it's nice if the library works with MSVC too ;)
Only if you don't export anything does mingw default to the *nix behaviour of exporting all the symbols. So either export all (which is what I recommend), or don't export anything.
@Joel-Bodenmann said in Undefined reference when linking against custom library DLL:
However, the issue remains:
It does look like the usual missing symbols. Make sure you're linking correctly against release/debug binary - on windows these are different libraries. Could you check if said symbols are really exported in the binary? I would imagine not ...
PS. I couldn't find your export header in the repository ... please don't tell me you're generating it on the fly ...
@kshegunov said in Undefined reference when linking against custom library DLL:
PS. I couldn't find your export header in the repository ... please don't tell me you're generating it on the fly ...
It's generated automatically by cmake in the build dir.
-
@Joel-Bodenmann said in Undefined reference when linking against custom library DLL:
It works without but it's nice if the library works with MSVC too ;)
Only if you don't export anything does mingw default to the *nix behaviour of exporting all the symbols. So either export all (which is what I recommend), or don't export anything.
@Joel-Bodenmann said in Undefined reference when linking against custom library DLL:
However, the issue remains:
It does look like the usual missing symbols. Make sure you're linking correctly against release/debug binary - on windows these are different libraries. Could you check if said symbols are really exported in the binary? I would imagine not ...
PS. I couldn't find your export header in the repository ... please don't tell me you're generating it on the fly ...
@kshegunov said in Undefined reference when linking against custom library DLL:
PS. I couldn't find your export header in the repository ... please don't tell me you're generating it on the fly ...
As @Christian-Ehrlicher mentioned this gets generated by cmake's
generate_export_header()
function during the configuration stage.Your statement sounds like you'd have some wisdom/experience to share on this topic... ;-)
-
Your cmake is wrong:
add_library(${TARGET_SHARED} SHARED) target_compile_definitions( ${TARGET_SHARED} PRIVATE qschematic_shared_EXPORTS # We are building this library! ) target_link_libraries( ${TARGET_SHARED} PUBLIC qschematic-objs ) --> set(CMAKE_AUTOMOC ON) set(CMAKE_AUTOUIC ON) set(CMAKE_AUTORCC ON) add_library(${TARGET_SHARED} SHARED ${SOURCES_PRIVATE}) target_link_libraries(${TARGET_SHARED} PUBLIC Qt5::Core Qt5::Gui Qt5::Widgets ${QSCHEMATIC_DEPENDENCY_GPDS_TARGET} ) target_include_directories( ${TARGET_SHARED} PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}> # For qschematic_export.h $<BUILD_INTERFACE:${CMAKE_CURRENT_LIST_DIR}/..> $<INSTALL_INTERFACE:..> )
You can not simply add the same compiled object files for your static and dynamic lib since the sources for the dynamic lib need to be compiled with
qschematic_shared_EXPORTS
.
You also do not need to define qschematic_shared_EXPORTS by your own - cmake defines it for you.btw: when you want your source to be portable avoid g++ extensions like binary literals (and, or not instead && - it took me ages to change all the places so it can be compiled with msvc.
-
@kshegunov said in Undefined reference when linking against custom library DLL:
PS. I couldn't find your export header in the repository ... please don't tell me you're generating it on the fly ...
As @Christian-Ehrlicher mentioned this gets generated by cmake's
generate_export_header()
function during the configuration stage.Your statement sounds like you'd have some wisdom/experience to share on this topic... ;-)
@Joel-Bodenmann said in Undefined reference when linking against custom library DLL:
As @Christian-Ehrlicher mentioned this gets generated by cmake's generate_export_header() function during the configuration stage.
... that's beautiful ...
Your statement sounds like you'd have some wisdom/experience to share on this topic... ;-)
Nah! Another time.
-
Your cmake is wrong:
add_library(${TARGET_SHARED} SHARED) target_compile_definitions( ${TARGET_SHARED} PRIVATE qschematic_shared_EXPORTS # We are building this library! ) target_link_libraries( ${TARGET_SHARED} PUBLIC qschematic-objs ) --> set(CMAKE_AUTOMOC ON) set(CMAKE_AUTOUIC ON) set(CMAKE_AUTORCC ON) add_library(${TARGET_SHARED} SHARED ${SOURCES_PRIVATE}) target_link_libraries(${TARGET_SHARED} PUBLIC Qt5::Core Qt5::Gui Qt5::Widgets ${QSCHEMATIC_DEPENDENCY_GPDS_TARGET} ) target_include_directories( ${TARGET_SHARED} PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}> # For qschematic_export.h $<BUILD_INTERFACE:${CMAKE_CURRENT_LIST_DIR}/..> $<INSTALL_INTERFACE:..> )
You can not simply add the same compiled object files for your static and dynamic lib since the sources for the dynamic lib need to be compiled with
qschematic_shared_EXPORTS
.
You also do not need to define qschematic_shared_EXPORTS by your own - cmake defines it for you.btw: when you want your source to be portable avoid g++ extensions like binary literals (and, or not instead && - it took me ages to change all the places so it can be compiled with msvc.
@Christian-Ehrlicher said in Undefined reference when linking against custom library DLL:
You can not simply add the same compiled object files for your static and dynamic lib since the sources for the dynamic lib need to be compiled with qschematic_shared_EXPORTS.
You also do not need to define qschematic_shared_EXPORTS by your own - cmake defines it for you.I see - that makes sense. I'm gonna change that!
@Christian-Ehrlicher said in Undefined reference when linking against custom library DLL:
btw: when you want your source to be portable avoid g++ extensions like binary literals (and, or not instead && - it took me ages to change all the places so it can be compiled with msvc.
As far as I can tell the
and
,or
,not
and similar keywords are actually part of the C++ standard. It's just that MSVC doesn't have support for them enabled by default - am I wrong here?I'd appreciate any kind of patch you want to submit tho. Making this library as portable as possible is certainly something I'd like to achieve. So far I've used it only with GCC and Clang.
@kshegunov said in Undefined reference when linking against custom library DLL:
... that's beautiful ...
Given your other messages I'm actually not sure whether that's sarcasm or not...? :p
-
@Joel-Bodenmann said in Undefined reference when linking against custom library DLL:
As far as I can tell the and, or, not and similar keywords are actually part of the C++ standard.
Yes (http://www.cplusplus.com/reference/ciso646/), but MSVC doesn't like them and it's not widely used. Also I find it very hard to read, esp. when you mix both versions in one line as you did :)
I can provide a patch for it if you want.I'm gonna change that!
I think all should compile then correctly. Tested it with your demo application.
-
@Christian-Ehrlicher said in Undefined reference when linking against custom library DLL:
You can not simply add the same compiled object files for your static and dynamic lib since the sources for the dynamic lib need to be compiled with qschematic_shared_EXPORTS.
You also do not need to define qschematic_shared_EXPORTS by your own - cmake defines it for you.I see - that makes sense. I'm gonna change that!
@Christian-Ehrlicher said in Undefined reference when linking against custom library DLL:
btw: when you want your source to be portable avoid g++ extensions like binary literals (and, or not instead && - it took me ages to change all the places so it can be compiled with msvc.
As far as I can tell the
and
,or
,not
and similar keywords are actually part of the C++ standard. It's just that MSVC doesn't have support for them enabled by default - am I wrong here?I'd appreciate any kind of patch you want to submit tho. Making this library as portable as possible is certainly something I'd like to achieve. So far I've used it only with GCC and Clang.
@kshegunov said in Undefined reference when linking against custom library DLL:
... that's beautiful ...
Given your other messages I'm actually not sure whether that's sarcasm or not...? :p
@Joel-Bodenmann said in Undefined reference when linking against custom library DLL:
Given your other messages I'm actually not sure whether that's sarcasm or not...? :p
It is, but you should drop it, I don't want to butt heads with Christian again, I'm too old and frail for that.
-
@Christian-Ehrlicher I have fixed the cmake as per you guidance: No longer building the static and shared libraries from the object library but instead creating them separately. I created a function to setup the stuff common to all targets. Now I can successfully build my Qt5 app/plugin :)
Here's the change I made: https://github.com/simulton/QSchematic/commit/98af6cc914b3340be7f36e9c3a4c7f7057093f97
Now I just have to do that for the GPDS dependency as well.@Christian-Ehrlicher said in Undefined reference when linking against custom library DLL:
Also I find it very hard to read, esp. when you mix both versions in one line as you did :)
I fully agree regarding consistency. This library started off as a hobby project of mine many years ago with a lot less C++ experience on my side. I am currently in the progress of cleaning everything up - hence also this entire fuzz.
As usual: I am very open towards feedback & criticism - My only goal is to make this library become a ready-to-use solution for whoever sees fit in using it.@Christian-Ehrlicher said in Undefined reference when linking against custom library DLL:
I can provide a patch for it if you want.
Patches are certainly appreciated :)