c语言srclist的用法,如何使用CMakeLists.txt和AndroidStudio将libxml2本...

经过一番搜索和努力,我找到了解决方案.所以我想按照以下步骤回答我自己的问题:

2.在项目中的适当位置添加所需的所有源代码和头文件.

3.借助Android.bp文件,我设法配置了我的app / CMakeList.txt

4.配置您的应用程序或库级别的build.gradle文件.

这是我的CMakeLists.txt:

cmake_minimum_required(VERSION 3.4.1)

set(LIBXML2_SOURCES

src/main/cpp/libxml2/src/SAX.c

src/main/cpp/libxml2/src/entities.c

src/main/cpp/libxml2/src/encoding.c

src/main/cpp/libxml2/src/error.c

src/main/cpp/libxml2/src/parserInternals.c

src/main/cpp/libxml2/src/parser.c

src/main/cpp/libxml2/src/tree.c

src/main/cpp/libxml2/src/hash.c

src/main/cpp/libxml2/src/list.c

src/main/cpp/libxml2/src/xmlIO.c

src/main/cpp/libxml2/src/xmlmemory.c

src/main/cpp/libxml2/src/uri.c

src/main/cpp/libxml2/src/valid.c

src/main/cpp/libxml2/src/xlink.c

src/main/cpp/libxml2/src/debugXML.c

src/main/cpp/libxml2/src/xpath.c

src/main/cpp/libxml2/src/xpointer.c

src/main/cpp/libxml2/src/xinclude.c

src/main/cpp/libxml2/src/DOCBparser.c

src/main/cpp/libxml2/src/catalog.c

src/main/cpp/libxml2/src/globals.c

src/main/cpp/libxml2/src/threads.c

src/main/cpp/libxml2/src/c14n.c

src/main/cpp/libxml2/src/xmlstring.c

src/main/cpp/libxml2/src/buf.c

src/main/cpp/libxml2/src/xmlregexp.c

src/main/cpp/libxml2/src/xmlschemas.c

src/main/cpp/libxml2/src/xmlschemastypes.c

src/main/cpp/libxml2/src/xmlunicode.c

src/main/cpp/libxml2/src/xmlreader.c

src/main/cpp/libxml2/src/relaxng.c

src/main/cpp/libxml2/src/dict.c

src/main/cpp/libxml2/src/SAX2.c

src/main/cpp/libxml2/src/xmlwriter.c

src/main/cpp/libxml2/src/legacy.c

src/main/cpp/libxml2/src/chvalid.c

src/main/cpp/libxml2/src/pattern.c

src/main/cpp/libxml2/src/xmlsave.c

src/main/cpp/libxml2/src/xmlmodule.c

src/main/cpp/libxml2/src/schematron.c

)

include_directories(src/main/cpp/libxml2/include)

include_directories(src/main/cpp/libxml2/src)

add_library( # Sets the name of the library.

myexampe-native

# Sets the library as a shared library.

SHARED

# Provides a relative path to your source file(s).

src/main/cpp/my-native.cpp )

add_library( # Sets the name of the library.

mylibxml2

# Sets the library as a shared library.

SHARED

# Provides a relative path to your source file(s).

${LIBXML2_SOURCES} )

target_link_libraries( # Specifies the target library.

myexampe-native

mylibxml2

)

这是我的app / build.gradle配置

android { .....

defaultConfig { .....

externalNativeBuild {

cmake {

cppFlags "-std=gnu++11"

arguments '-DANDROID_PLATFORM=android-21',

'-DANDROID_STL=c++_shared','-DANDROID_ARM_MODE=arm'

}

}

欢迎对任何澄清发表评论.

谢谢 :-)

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值