c++ - Wl,--stack,4194304 错误 Visual Studio/CMake

标签 c++ visual-studio-2015 compiler-errors cmake

所以我使用 CMake 构建了一个开源项目并在 Visual Studio 中打开它,但我收到此错误:

Command line error D8021: invalid numeric argument '/Wl,--stack,4194304'

我的 CMakeLists.txt 有这个:

if(WIN32) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wl,--stack,4194304 -fpermissive") endif()

我不确定这是什么或如何修复。感谢任何帮助

最佳答案

您正在为 GCC 提供 Visual Studio 编译器开关。

if (WIN32)
  if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
     set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wl,--stack,4194304 -fpermissive")
  elseif(MSVC)
    # add options for Visual C/C++ Compiler here
    set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /F 4194304")
  endif()
endif()

另见 In cmake, how can I test if the compiler is Clang?如何可靠地识别您的编译器。

有关许可标志,请参阅 Visual Studio (2015) fpermissive equivalent flag .

编辑:根据讨论为 GCC 添加了更可靠的编译器检查。

关于c++ - Wl,--stack,4194304 错误 Visual Studio/CMake,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49547268/

相关文章:

c# - 编辑功能文件时,SpecFlow .feature.cs 文件会重复

visual-studio - Visual Studio 2015 无法启动 : side-by-side configuration is incorrect

c# - 用于 Unity3D 的 Visual Studio 2015 错误 "Incompatible Project"

c# - 向 C# 程序添加全局变量时必须删除 [STAThread] 吗?

c++ - 混合使用 C 和 C++ 代码会在 GCC 中产生意外行为

c# - std::vector::iterators 在 C# 中的等效项是什么?

c++ - 引用指针 vs 通过引用传递?

c++ - C++ 中循环移位的问题

c++ - 之前的C++错误主要表达

compiler-errors - cx_Freeze 错误 : resource_filename() only supported for . 鸡蛋不是 .zip