gpt4 book ai didi

c++ - Windows 上的 Qt5 项目与 MinGW

转载 作者:行者123 更新时间:2023-11-28 03:09:13 25 4
gpt4 key购买 nike

我一直在为 Qt/C++ 项目使用 Visual Studio 2012。

我正在尝试迁移到 MinGW,这样我就可以完全使用 C++11 而不是 MSFT 编译器提供的部分支持。使用 CMake 生成项目并进行得非常顺利,编译了所有子项目和主项目本身。

但是,链接给了我一些错误,我不确定如何解决它们:

Linking CXX executable 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): undefined reference to __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): undefined reference to __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): undefined reference to __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): undefined reference to __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): bad reloc address 0xf in section `.text$_ZNSt9exceptionC2Ev[_ZNSt9exceptionC2Ev]' collect2.exe: error: ld returned 1 exit status Deltas\CMakeFiles\Owl.dir\build.make:1217: recipe for target 'Deltas/Owl.exe' failed mingw32-make[2]: * [Deltas/Owl.exe] Error 1 CMakeFiles\Makefile2:435: recipe for target 'Deltas/CMakeFiles/Owl.dir/all' failed mingw32-make[1]: [Deltas/CMakeFiles/Owl.dir/all] Error 2 Makefile:115: recipe for target 'all' failed mingw32-make: ** [all] Error 2

该项目使用 Visual Studio(和 Xcode、FWIW)编译和链接得很好,所以我不确定链接器缺少什么。

有人可以提供任何建议吗?

最佳答案

您需要为 MinGW 下载 Qt(或者您自己构建它,如果您使用的 MinGW 版本与构建 Qt 版本的版本不同。)Qt 的 VS 版本不能与 MinGW 一起使用。

关于c++ - Windows 上的 Qt5 项目与 MinGW,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18935487/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com