我一直在将 Visual Studio 2012 用于 Qt/C++ 项目。
我正在尝试迁移到 MinGW,以便我可以完全使用 C++11,而不是 MSFT 编译器提供的部分支持。使用 CMake 生成项目并制作非常顺利,编译了所有子项目和主项目本身。
但是,链接给了我一些错误,我不知道如何解决它们:
链接 CXX 可执行文件 Owl.exe CMakeFiles\Owl.dir/objects.a(BoardTreeView.cpp.obj):BoardTreeView.cpp:(.text+0x1e): undefined reference to
__imp__ZN9QTreeViewC2EP7QWidget' CMakeFiles\Owl.dir/objects.a(BoardTreeView.cpp.obj):BoardTreeView.cpp:(.text+0x7b): undefined reference to
_ imp _ZN9QTreeViewD2Ev' CMakeFiles\Owl.dir/objects.a (BoardTreeView.cpp.obj):BoardTreeView.cpp:(.text+0x116): 未定义引用__imp__ZNK17QAbstractItemView5modelEv' CMakeFiles\Owl.dir/objects.a(BoardTreeView.cpp.obj):BoardTreeView.cpp:(.text+0x1a1): undefined reference to
_imp _ZNK18QStandardItemModel9findItemsERK7QString6QFlagsIN2Qt9MatchFlagEEi ' CMakeFiles\Owl.dir/objects.a(BoardTreeView.cpp.obj):BoardTreeView.cpp:(.text +0x303): 未定义引用__imp__ZN8QVariantD1Ev' CMakeFiles\Owl.dir/objects.a(BoardTreeView.cpp.obj):BoardTreeView.cpp:(.text+0x350): undefined reference to
_imp _ZeqRK7QStringS1_ ' CMakeFiles\Owl.dir/objects.a(BoardTreeView.cpp.obj):BoardTreeView.cpp:(.text+ 0x53e ): 未定义引用__imp__ZN8QVariantD1Ev' CMakeFiles\Owl.dir/objects.a(BoardTreeView.cpp.obj):BoardTreeView.cpp:(.text+0x649): undefined reference to
_imp_ZNK9QTreeView10indexBelowERK11QModelIndex' CMakeFiles\Owl.dir/objects.a(BoardTreeView.cpp.obj):BoardTreeView.cpp:(.text+0x669): undefined reference to__imp__ZNK17QAbstractItemView5modelEv' CMakeFiles\Owl.dir/objects.a(BoardTreeView.cpp.obj):BoardTreeView.cpp:(.text+0x6b1): undefined reference to
_ imp _ZN17QAbstractItemView15setCurrentIndexERK11QModelIndex' CMakeFiles\Owl.dir/objects.a(BoardTreeView.cpp .obj):BoardTreeView.cpp:(.text+ 0x6c1 ): 未定义引用__imp__ZN8QVariantD1Ev' CMakeFiles\Owl.dir/objects.a(BoardTreeView.cpp.obj):BoardTreeView.cpp:(.text+0x6d6): undefined reference to
_imp_ZN8QVariantD1Ev' c:/progra~1/mingw-~1/x64-48~1.1-p/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/4.8.1/../../. ./../x86_64-w64-mingw32/bin/ld.exe: CMakeFiles\Owl.dir/objects.a(BoardTreeView.cpp.obj): `.text$_ZNSt9exceptionC2Ev[_ZNSt9exceptionC2Ev]' 部分中的错误重定位地址 0xf'collect2 .exe: 错误: ld 返回 1 退出状态 Deltas\CMakeFiles\Owl.dir\build.make:1217: 目标 'Deltas/Owl.exe' 的配方失败 mingw32-make[2]: * [Deltas/Owl.exe]错误 1 CMakeFiles\Makefile2:435:目标“Deltas/CMakeFiles/Owl.dir/all”的配方失败 mingw32-make[1]: [Deltas/CMakeFiles/Owl.dir/all] 错误 2 Makefile:115: 目标“所有”的配方失败 mingw32-make: * * [all] 错误 2
该项目使用 Visual Studio(和 Xcode、FWIW)编译和链接得很好,所以我不确定链接器缺少什么。
任何人都可以提供任何建议吗?