欢迎访问 生活随笔!

生活随笔

当前位置: 首页 > 编程资源 > 编程问答 >内容正文

编程问答

【错误记录】Visual Studio 中编译 NDK 报错 ( error : cannot use ‘throw‘ with exceptions disabled )

发布时间:2025/6/17 编程问答 46 豆豆
生活随笔 收集整理的这篇文章主要介绍了 【错误记录】Visual Studio 中编译 NDK 报错 ( error : cannot use ‘throw‘ with exceptions disabled ) 小编觉得挺不错的,现在分享给大家,帮大家做个参考.

文章目录

  • 一、报错信息
  • 二、解决方案





一、报错信息



使用 Visual Studio 2019 编译 Android NDK 项目 , 报错如下 :

已启动生成… 1>------ 已启动生成: 项目: native, 配置: Debug ARM ------ 1>ANDROID_HOME=D:\\Microsoft\AndroidSDK\25 1>ANT_HOME=D:\001_Develop\017_Microsoft Visual Studio\2019\Community\Apps\apache-ant-1.9.3 1>JAVA_HOME=C:\Program Files\Android\jdk\microsoft_dist_openjdk_1.8.0.25 1>NDK_ROOT=D:\\Microsoft\AndroidNDK64\android-ndk-r16b 1>json_reader.cpp 1>json\json_reader.cpp(1129,14): error : cannot use 'throw' with exceptions disabled 1> if (!ok) throw std::runtime_error(reader.getFormatedErrorMessages()); 1> ^ 1>1 error generated. 1>已完成生成项目“native.vcxproj”的操作 - 失败。 ========== 生成: 成功 0 个,失败 1 个,最新 0 个,跳过 0==========





二、解决方案



在项目属性中设置 " 启动 C++ 异常 " 项为 " 是 ( -fexception ) " 选项 ;


如果使用 Android.mk 构建项目 , 可以添加 LOCAL_CPP_FEATURES += exceptions 或 LOCAL_CPPFLAGS += -fexceptions 配置 ;

也可以在 Application.mk 中配置 APP_CPPFLAGS += -fexceptions ;

总结

以上是生活随笔为你收集整理的【错误记录】Visual Studio 中编译 NDK 报错 ( error : cannot use ‘throw‘ with exceptions disabled )的全部内容,希望文章能够帮你解决所遇到的问题。

如果觉得生活随笔网站内容还不错,欢迎将生活随笔推荐给好友。