Qt MinGW编译出现obj file too big问题
Qt MinGW编译出现obj file too big问题,提示需要添加Wa,-mbig-obj。对应cmake中怎么添加-Wa,-mbig-obj?
在 CMake 中添加编译器标志,比如 -Wa,-mbig-obj
,可以通过几种方法实现。这个标志通常用于 GCC 或类似编译器,用以增加生成的单个对象的最大大小限制。以下是几种在 CMake 中添加此标志的方法:
方法 1:使用 add_compile_options
在 CMakeLists.txt 文件中,你可以使用 add_compile_options
命令来添加编译选项。这会将选项应用于所有接下来的目标(targets)。
add_compile_options(-Wa,-mbig-obj)
方法 2:使用 target_compile_options
如果你只想为特定的目标(target)添加此选项,可以使用 target_compile_options
。这在你需要为不同的目标使用不同编译选项时特别有用。
add_executable(my_target main.cpp)
target_compile_o