You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

CMake编译ZynAddSubFX时GCC无法读取参数文件的问题求助

解决CMake构建ZynAddSubFX时的rtosc头文件找不到问题

问题现象

编译时出现头文件找不到错误:

D:/work/zyn-fusion-build/src/zynaddsubfx/rtosc/src/rtosc.c:9:10: fatal error: rtosc/rtosc.h: No such file or directory
    9 | #include <rtosc/rtosc.h>
      |          ^~~~~~~~~~~~~~~
compilation terminated.

对应的简化编译命令:

gcc @CMakeFiles/rtosc.dir/includes_C.rsp -O2 -fPIC -std=c99 -Wall -Wextra -MD -MT rtosc/CMakeFiles/rtosc.dir/src/rtosc.c.obj -MF CMakeFiles/rtosc.dir/src/rtosc.c.obj.d -o CMakeFiles/rtosc.dir/src/rtosc.c.obj -c /g/Projects/zyn-fusion-build/src/zynaddsubfx/rtosc/src/rtosc.c

当前文件系统结构:

.
├── CMakeFiles
│	├── CMakeDirectoryInformation.cmake
│	└── rtosc.dir
│		├── DependInfo.cmake
│		├── build.make
│		├── cmake_clean.cmake
│		├── cmake_clean_target.cmake
│		├── compiler_depend.make
│		├── compiler_depend.ts
│		├── depend.make
│		├── flags.make
│		├── includes_C.rsp
│		├── link.txt
│		├── progress.make
│		└── src
├── CTestTestfile.cmake
├── Makefile
└── cmake_install.cmake

将@CMakeFiles/rtosc.dir/includes_C.rsp替换为文件实际内容后编译正常,但无法直接编辑Makefile(CMake会重新生成)。

补充信息

  • 相关CMakeLists.txt片段:
add_library(rtosc src/rtosc.c src/dispatch.c src/rtosc-time.c)
target_include_directories(rtosc PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/include)
  • includes_C.rsp文件内容:
-I"/g/Projects/zyn-fusion-build/src/zynaddsubfx/rtosc/include"
  • GCC版本:
$ gcc --version
gcc.exe (Rev4, Built by MSYS2 project) 12.2.0
Copyright (C) 2022 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

解决方案

问题根源是MSYS2环境下的GCC对响应文件(.rsp)中带引号的-I参数解析异常。直接禁用CMake使用响应文件传递include参数即可:

  1. 在rtosc模块的CMakeLists.txt中添加以下配置:
# 禁用使用响应文件传递C语言的include参数
set(CMAKE_C_USE_RESPONSE_FILE_FOR_INCLUDES OFF)
  1. 重新运行CMake生成构建文件并编译:
cmake --build . --clean-first

这样CMake会直接将所有-I参数展开到编译命令行中,绕过响应文件的引号解析问题,编译即可正常进行。

内容的提问来源于stack exchange,提问作者jackapple117

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.16 22:45:39