我的环境
报错信息:
不知道怎么解决
版本是足够新的,汇编器报错就很奇怪了,之前从来没遇到过。难道是 GCC 的代码生成有什么奇怪的特性,导致生成出来的汇编转化成 EXE 出错?
感觉这个问题需要我们做更多测试才有可能解决。建议你先考虑一下更换工具链,比如改用 msys2 的 mingw 工具链,或者直接装 Visual Studio 改用 MSVC 工具链。
MSVC 的版本
cmake -S .. -B . -DCMAKE_BUILD_TYPE=Debug -G "Visual Studio 17 2022"
-- Selecting Windows SDK version 10.0.22621.0 to target Windows 10.0.22631.
-- The C compiler identification is MSVC 19.41.34120.0
-- The CXX compiler identification is MSVC 19.41.34120.0
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: F:/Visual Studio 2022/VC/Tools/MSVC/14.41.34120/bin/Hostx64/x64/cl.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: F:/Visual Studio 2022/VC/Tools/MSVC/14.41.34120/bin/Hostx64/x64/cl.exe - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
Current build type: Debug
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD - Failed
-- Looking for pthread_create in pthreads
-- Looking for pthread_create in pthreads - not found
-- Looking for pthread_create in pthread
-- Looking for pthread_create in pthread - not found
-- Found Threads: TRUE
-- Using Win32 for window creation
-- {fmt} version: 11.0.2
-- Build type: Debug
-- Shared libraries disabled
-- compiling zlib from sources
-- Looking for sys/types.h
-- Looking for sys/types.h - found
-- Looking for stdint.h
-- Looking for stdint.h - found
-- Looking for stddef.h
-- Looking for stddef.h - found
-- Check size of off64_t
-- Check size of off64_t - failed
-- Looking for fseeko
-- Looking for fseeko - not found
-- Looking for unistd.h
-- Looking for unistd.h - not found
-- Enabled importer formats: COLLADA OBJ FBX
-- Disabled importer formats: AMF 3DS AC ASE ASSBIN B3D BVH DXF CSM HMP IRRMESH IQM IRR LWO LWS M3D MD2 MD3 MD5 MDC MDL NFF NDO OFF OGRE OPENGEX PLY MS3D COB BLEND IFC XGL Q3D Q3BSP RAW SIB SMD STL TERRAGEN 3D X X3D GLTF 3MF MMD
-- Enabled exporter formats:
-- Disabled exporter formats: OBJ OPENGEX PLY 3DS ASSBIN ASSXML M3D COLLADA FBX STL X X3D GLTF 3MF PBRT ASSJSON STEP
-- Treating all warnings as errors (for assimp library only)
-- Configuring done (27.6s)
-- Generating done (0.1s)
-- Build files have been written to: F:/tools/dandelion-main/build
额外节选一些有问题的地方
1
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD - Failed
-- Looking for pthread_create in pthreads
-- Looking for pthread_create in pthreads - not found
-- Looking for pthread_create in pthread
-- Looking for pthread_create in pthread - not found
2
-- Check size of off64_t
-- Check size of off64_t - failed
-- Looking for fseeko
-- Looking for fseeko - not found
-- Looking for unistd.h
-- Looking for unistd.h - not found
虽然不知道这些文件是什么,但似乎不影响文件的构建
之后进行编译
输入指令
cmake --build . --config Debug --target dandelion --parallel 8
得到下面结果
适用于 .NET Framework MSBuild 版本 17.11.9+a69bbaaf5
1>Checking Build System
Building Custom Rule F:/tools/dandelion-main/deps/assimp/contrib/zlib/CMakeLists.txt
Building Custom Rule F:/tools/dandelion-main/deps/fmt/CMakeLists.txt
Building Custom Rule F:/tools/dandelion-main/deps/glfw/src/CMakeLists.txt
context.c
adler32.c
compress.c
crc32.c
deflate.c
gzclose.c
gzlib.c
gzread.c
gzwrite.c
inflate.c
infback.c
inftrees.c
inffast.c
trees.c
uncompr.c
zutil.c
cl : 命令行 error D8021: 无效的数值参数“/Wa,-mbig-obj” [F:\tools\dandelion-main\build\deps\fmt\fmt.vcxproj]
init.c
input.c
zlibstatic.vcxproj -> F:\tools\dandelion-main\build\deps\assimp\contrib\zlib\Debug\zlibstaticd.lib
monitor.c
Building Custom Rule F:/tools/dandelion-main/deps/assimp/code/CMakeLists.txt
vulkan.c
window.c
cl : 命令行 error D8021: 无效的数值参数“/Wa,-mbig-obj” [F:\tools\dandelion-main\build\deps\assimp\code\assimp.vcxproj]
win32_init.c
win32_joystick.c
win32_monitor.c
win32_time.c
win32_thread.c
win32_window.c
wgl_context.c
egl_context.c
osmesa_context.c
正在生成代码...
glfw.vcxproj -> F:\tools\dandelion-main\build\deps\glfw\src\Debug\glfw3.lib
有两处一样的报错
cl : 命令行 error D8021: 无效的数值参数“/Wa,-mbig-obj”
查找资料显示出错原因是 Visual Studio 的 cl.exe
编译器不支持 GCC
/MinGW
常用的 -Wa,-mbig-obj
参数。这个参数通常用于处理大对象文件,特别是在某些库(如 fmt
和 assimp
)的编译中。但它是针对 GCC 和 MinGW 编译器的参数,而 cl.exe
作为 MSVC 的编译器,不认识这个参数。
这该怎么处理