Issue
I'm trying to do matrix multiplication in Android Studio and want to use c++ for the speed benefit. I found the library xtensor and think that it will be useful but I cant get working. I tried putting the header files into the cpp folder but then they dont have access to the base library dependencies and I've been researching for hours now but I couldn't find out exactly what to write in the CMakeLists.txt and how libraries are actually meant to be installed. I'm sorry if this is really obvious but I can't really wrap my head around it.
How can I install the xtensor library in android studio or is there some other way? I wanted to avoid using for loops for the calculation but if there's no other possibility I guess I have to..
Solution
How can I install the xtensor library in android studio or is there some other way? I wanted to avoid using for loops for the calculation but if there's no other possibility I guess I have to..
xtensor
project is based on cmake
which is supported by AndroidStudio(gradle)
so you can easily use it for NDK build.
It takes just a few steps to integrate xtensor
into your project (without installing it into the system):
- Fetch
xtensor
andxtl
(xtensor
depends onxtl
) projects and add them to your root cmake, for example:
add_subdirectory(external/xtl)
add_subdirectory(external/xtensor)
- Create
Findxtl.cmake
to supportfind_package(xtl)
. It's enough only to setxtl_FOUND
:
set(xtl_FOUND TRUE)
- And the last step is to link your native library to the
xtensor
interface library:
add_library(native-lib SHARED native-lib.cpp)
target_link_libraries(native-lib xtensor)
Here an example how it can be done for Android Studio Native C++ Template Project
based on "Initialize a 2-D array and compute the sum of one of its rows and a 1-D array" example from xtensor/basic-usage.
Answered By - Mykola Khyliuk
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.