最近需要给安卓平台的应用程序提供c++开发的算法库,c++又用到了opencv开源库,不想使用Android Studio,用惯了VS,因此,写下VS跨平台开发安卓动态库的配置步骤。
参考链接:https://answers.opencv.org/question/179297/how-to-build-opencv-for-android-using-visual-studio/
https://blog.youkuaiyun.com/luoyu510183/article/details/94590497
官方说明文档(用于跨平台移动开发的 Visual C++):https://docs.microsoft.com/zh-cn/visualstudio/cross-platform/visual-cpp-for-cross-platform-mobile-development?view=vs-2017
(使用 C++ 安装跨平台移动开发)https://docs.microsoft.com/zh-cn/visualstudio/cross-platform/install-visual-cpp-for-cross-platform-mobile-development?view=vs-2017
第一步更改VS
选择更多-修改-工作负载-移动与游戏-使用c++的移动开发
选择安装,等待安装完成。
第二步配置VS:Setting up Visual Studio
- Create a new Visual Studio Project from "Visual C++/Cross Platform/Android" and choose the type of Project you want.
- Add the path "Path_to_build_folder/install/sdk/native/jni/include" to "Additional Include directories" and both the "native/3rdparty/libs/armeabi-v7a/" and "native/libs/armeabi-v7a/" to "Additional Library Directories".
- In your projects property dialog change "Enable C++ Exceptions" to "Yes (-fexceptions)" under "C/C++ - Code Generation" and "Enable Run-Time Type Information" to "Yes (-frtti)" as well. You can find it under "C/C++ - Language". Also add "-std=c++11" as Additional Option in the Command Line Section of "C/C++".
- In the Linker section of your property page, add "-lm -lz" to the command line additional options. This ensures correct linking.
- Under "Linker/Input", add all your built modules and also the 3rdparty libs as "Library Dependencies". Important: Only their names, e.g. not &