Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CMake error:找不到Ninja #579

Open
beiyuming opened this issue Dec 16, 2024 · 7 comments
Open

CMake error:找不到Ninja #579

beiyuming opened this issue Dec 16, 2024 · 7 comments

Comments

@beiyuming
Copy link

已经按文档命令尝试构建,但是cmake提示找不到Ninja,且CMAKE_MAKE_PROGRAM 没有设置
cmake完整指令及报错:
$ cmake -DCMAKE_PREFIX_PATH="D:\CS\QT\6.8.1\mingw_64" -DCMAKE_BUILD_TYPE=Release -GNinja "D:\CS\QT\projects\FluentUI" CMake Error: CMake was unable to find a build program corresponding to "Ninja". CMAKE_MAKE_PROGRAM is not set. You probably need to sel ect a different build tool. CMake Error: CMAKE_C_COMPILER not set, after EnableLanguage CMake Error: CMAKE_CXX_COMPILER not set, after EnableLanguage -- Configuring incomplete, errors occurred!

@Hzlin7
Copy link
Contributor

Hzlin7 commented Dec 17, 2024

可以手动安装Ninja或者使用Qt Maintenance Tool选择安装Ninja组件

@beiyuming
Copy link
Author

可以手动安装Ninja或者使用Qt Maintenance Tool选择安装Ninja组件

非常感谢,是这个问题没错,我在环境变量Path里加上nanja解决这个报错。
但是还是无法编译,不知道是否是因为默认选择编译器问题?(电脑里有多个mingw,且qt的mingw并没有加到系统变量中,其次gt的g++编译器似乎不在<QT_SDK_DIR_PATH>的mingw而在其QT目录的tool工具下的mingw。原谅我对构建原理不太熟悉,昨晚尝试一晚上都没办法配好这个环境 T T
undefined reference to qUnregisterResourceData(int, unsigned char const*,
unsigned char const*, unsigned char const*)'
src/CMakeFiles/fluentuiplugin.dir/qrc_fluentui.cpp.obj:qrc_fluentui.cpp:(.text.s
tartup+0x1f): undefined reference to qRegisterResourceData(int, unsigned char c onst*, unsigned char const*, unsigned char const*)' collect2.exe: error: ld returned 1 exit status ninja: build stopped: subcommand failed.

@beiyuming
Copy link
Author

可以手动安装Ninja或者使用Qt Maintenance Tool选择安装Ninja组件

我系统变量里的g++ 是8.1,而qt安装的g++是13.1(没有加到系统变量中),是否是因为这个原因导致Undefine呢?我想直接将系统变量里的g++路径换成qt的,但是我不清楚这两个mingw是否有什么特殊区别,不知道可不可以这么做。
以下是我运行Camke的命令及其提示信息:

$ cmake -DCMAKE_PREFIX_PATH="D:\CS\QT\6.8.1\mingw_64" -DCMAKE_BUILD_TYPE=Release -GNinja "D:\CS\QT\projects\FluentUI"
-- The C compiler identification is GNU 8.1.0
-- The CXX compiler identification is GNU 8.1.0
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: D:/CS/mingw64/bin/gcc.exe - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: D:/CS/mingw64/bin/c++.exe - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Current .git exist
-- Current git tag: 1.7.7, commit count: 1454, describe: 1.7.7-54-ga8ca78f3
-- Current semver: major: 1, minor: 7, patch: 7, counter: 10707
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD - Failed
-- Check if compiler accepts -pthread
-- Check if compiler accepts -pthread - yes
-- Found Threads: TRUE
-- Performing Test HAVE_STDATOMIC
-- Performing Test HAVE_STDATOMIC - Success
-- Found WrapAtomic: TRUE
-- Could NOT find WrapVulkanHeaders (missing: Vulkan_INCLUDE_DIR)
-- Could NOT find WrapVulkanHeaders (missing: Vulkan_INCLUDE_DIR)

@beiyuming
Copy link
Author

可以手动安装Ninja或者使用Qt Maintenance Tool选择安装Ninja组件

修改gcc路径后似乎还是一样的问题,实在不知道怎么办了T T
完整提示信息如下:
$ cmake -DCMAKE_PREFIX_PATH="D:\CS\QT\6.8.1\mingw_64" -DCMAKE_BUILD_TYPE=Release -GNinja "D:\CS\QT\projects\FluentUI"
-- The C compiler identification is GNU 13.1.0
-- The CXX compiler identification is GNU 13.1.0
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: D:/CS/QT/Tools/mingw1310_64/bin/gcc.exe - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: D:/CS/QT/Tools/mingw1310_64/bin/c++.exe - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Current .git exist
-- Current git tag: 1.7.7, commit count: 1454, describe: 1.7.7-54-ga8ca78f3
-- Current semver: major: 1, minor: 7, patch: 7, counter: 10707
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD - Success
-- Found Threads: TRUE
-- Performing Test HAVE_STDATOMIC
-- Performing Test HAVE_STDATOMIC - Success
-- Found WrapAtomic: TRUE
-- Could NOT find WrapVulkanHeaders (missing: Vulkan_INCLUDE_DIR)
-- Could NOT find WrapVulkanHeaders (missing: Vulkan_INCLUDE_DIR)
Def.h
FluAccentColor.cpp
FluAccentColor.h
FluApp.cpp
FluApp.h
FluCaptcha.cpp
FluCaptcha.h
FluColors.cpp
FluColors.h
FluFrameless.cpp
FluFrameless.h
FluHotkey.cpp
FluHotkey.h
FluQrCodeItem.cpp
FluQrCodeItem.h
FluRectangle.cpp
FluRectangle.h
FluTableModel.cpp
FluTableModel.h
FluTableSortProxyModel.cpp
FluTableSortProxyModel.h
FluTextStyle.cpp
FluTextStyle.h
FluTheme.cpp
FluTheme.h
FluTools.cpp
FluTools.h
FluTreeModel.cpp
FluTreeModel.h
FluWatermark.cpp
FluWatermark.h
FluentIconDef.h
FluentUI.cpp
FluentUI.h
fluentuiplugin.cpp
fluentuiplugin.h
qhotkey/qhotkey.cpp
qhotkey/qhotkey.h
qhotkey/qhotkey_mac.cpp
qhotkey/qhotkey_p.h
qhotkey/qhotkey_win.cpp
qhotkey/qhotkey_x11.cpp
qmlcustomplot/TimePlot.cpp
qmlcustomplot/TimePlot.h
qmlcustomplot/axis.cpp
qmlcustomplot/axis.h
qmlcustomplot/baseplot.cpp
qmlcustomplot/baseplot.h
qmlcustomplot/graph.cpp
qmlcustomplot/graph.h
qmlcustomplot/grid.cpp
qmlcustomplot/grid.h
qmlcustomplot/macros.h
qmlcustomplot/qcustomplot.cpp
qmlcustomplot/qcustomplot.h
qmlcustomplot/ticker.cpp
qmlcustomplot/ticker.h
qrcode/bitstream.cpp
qrcode/bitstream.h
qrcode/config.h
qrcode/mask.cpp
qrcode/mask.h
qrcode/mmask.cpp
qrcode/mmask.h
qrcode/mqrspec.cpp
qrcode/mqrspec.h
qrcode/qrencode.cpp
qrcode/qrencode.h
qrcode/qrencode_inner.h
qrcode/qrinput.cpp
qrcode/qrinput.h
qrcode/qrspec.cpp
qrcode/qrspec.h
qrcode/rsecc.cpp
qrcode/rsecc.h
qrcode/split.cpp
qrcode/split.h
singleton.h
stdafx.h
CMake Warning (dev) at D:/CS/QT/6.8.1/mingw_64/lib/cmake/Qt6Core/Qt6CoreMacros.cmake:3353 (message):
Qt policy QTP0004 is not set: You need qmldir files for each extra
directory that contains .qml files for your module. Check
https://doc.qt.io/qt-6/qt-cmake-policy-qtp0004.html for policy details.
Use the qt_policy command to set the policy and suppress this warning.

Call Stack (most recent call first):
D:/CS/QT/6.8.1/mingw_64/lib/cmake/Qt6Qml/Qt6QmlMacros.cmake:3299 (__qt_internal_setup_policy)
D:/CS/QT/6.8.1/mingw_64/lib/cmake/Qt6Qml/Qt6QmlMacros.cmake:896 (qt6_target_qml_sources)
D:/CS/QT/6.8.1/mingw_64/lib/cmake/Qt6Qml/Qt6QmlMacros.cmake:1232 (qt6_add_qml_module)
src/CMakeLists.txt:151 (qt_add_qml_module)
This warning is for project developers. Use -Wno-dev to suppress it.

-- Could NOT find WrapVulkanHeaders (missing: Vulkan_INCLUDE_DIR)
-- Could NOT find WrapVulkanHeaders (missing: Vulkan_INCLUDE_DIR)
------------------------ FluentUI ------------------------
Build FluentUI demo applications.: ON
Build static library.: OFF
Path to FluentUI plugin.:
-- Configuring done (4.6s)
-- Generating done (1.0s)
-- Build files have been written to: D:/CS/QT/projects/FluentUI/build

@beiyuming
Copy link
Author

尝试执行ninja后,也确实存在问题
部分提示截取如下:
[369/378] Building CXX object example/CMakeFiles/example.dir/example_autogen/mocs_compilation.cpp.obj
FAILED: example/CMakeFiles/example.dir/example_autogen/mocs_compilation.cpp.obj
D:\CS\QT\Tools\mingw1310_64\bin\c++.exe -DMINGW_HAS_SECURE_API=1 -DQT_CORE_LIB -DQT_GUI_LIB -DQT_MESSAGELOGCONTEXT -DQT_NEEDS_QMAIN -DQT_NETWORK_LIB -DQT_NO_DEBUG -DQT_OPENGL_LIB -DQT_PRINTSUPPORT_LIB -DQT_QMLI
NTEGRATION_LIB -DQT_QMLMETA_LIB -DQT_QMLMODELS_LIB -DQT_QMLWORKERSCRIPT_LIB -DQT_QML_LIB -DQT_QUICK_LIB -DQT_SVG_LIB -DQT_WIDGETS_LIB -DUNICODE -DWIN32 -DWIN64 -D_ENABLE_EXTENDED_ALIGNED_STORAGE -D_UNICODE -D_W
IN64 -ID:/CS/QT/projects/FluentUI/build/example -ID:/CS/QT/projects/FluentUI/example -ID:/CS/QT/projects/FluentUI/build/example/example_autogen/include -ID:/CS/QT/projects/FluentUI/example/src/component -isyste
m D:/CS/QT/6.8.1/mingw_64/include/QtCore -isystem D:/CS/QT/6.8.1/mingw_64/include -isystem D:/CS/QT/6.8.1/mingw_64/mkspecs/win32-g++ -isystem D:/CS/QT/6.8.1/mingw_64/include/QtQuick -isystem D:/CS/QT/6.8.1/ming
w_64/include/QtGui -isystem D:/CS/QT/6.8.1/mingw_64/include/QtQml -isystem D:/CS/QT/6.8.1/mingw_64/include/QtQmlIntegration -isystem D:/CS/QT/6.8.1/mingw_64/include/QtNetwork -isystem D:/CS/QT/6.8.1/mingw_64/in
clude/QtQmlMeta -isystem D:/CS/QT/6.8.1/mingw_64/include/QtQmlModels -isystem D:/CS/QT/6.8.1/mingw_64/include/QtQmlWorkerScript -isystem D:/CS/QT/6.8.1/mingw_64/include/QtOpenGL -isystem D:/CS/QT/6.8.1/mingw_64
/include/QtSvg -isystem D:/CS/QT/6.8.1/mingw_64/include/QtWidgets -isystem D:/CS/QT/6.8.1/mingw_64/include/QtPrintSupport -O3 -DNDEBUG -std=gnu++17 -MD -MT example/CMakeFiles/example.dir/example_autogen/mocs_co
mpilation.cpp.obj -MF example\CMakeFiles\example.dir\example_autogen\mocs_compilation.cpp.obj.d -o example/CMakeFiles/example.dir/example_autogen/mocs_compilation.cpp.obj -c D:/CS/QT/projects/FluentUI/build/exa
mple/example_autogen/mocs_compilation.cpp
In file included from D:/CS/QT/projects/FluentUI/build/example/example_autogen/mocs_compilation.cpp:11:
D:/CS/QT/projects/FluentUI/build/example/example_autogen/UVLADIE3JM/moc_AppInfo.cpp:34:8: error: redefinition of 'struct {anonymous}::qt_meta_tag_ZN7AppInfoE_t'
34 | struct qt_meta_tag_ZN7AppInfoE_t {};
| ^~~~~~~~~~~~~~~~~~~~~~~~~
In file included from D:/CS/QT/projects/FluentUI/build/example/example_autogen/mocs_compilation.cpp:2:

@Hzlin7
Copy link
Contributor

Hzlin7 commented Dec 18, 2024

可能是因为你使用的QT6.8.1导致的,项目中使用的是QT6.2.4,你可以重新安装QT6.2.4版本试下

@beiyuming
Copy link
Author

可能是因为你使用的QT6.8.1导致的,项目中使用的是QT6.2.4,你可以重新安装QT6.2.4版本试下

没有向前兼容吗o.O,我试试看吧

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants