Android Studio使用JNI来构建C/C ,但是C/C 需要另一个lib.a,如何解决
android studio use JNI to build c/c++ ,but the c/c++ need another lib.a, how to solve
关于Android Studio。当我编辑JNI以使用C/C 代码,但是C/C 代码使用另一个lib .a,那么我如何编辑我的cmakelist.txt,请帮助我,如果您擅长使用Android Studioenter Image Description
这是我的cmakelist.txt当我做项目时。它说"/../../mips64el-linux-android/bintroid/bin d:找不到-lwebsockets"
cmake_minimum_required(VERSION 3.4.1)
aux_source_directory(src/main/cpp/android_src/common FILE_COMMON)
aux_source_directory(src/main/cpp/android_src FILE_SRC)
aux_source_directory(src/main/cpp/ FILE_CPP)
SET(ALL_FILE ${FILE_CPP} ${FILE_SRC} ${FILE_CPP})
INCLUDE_DIRECTORIES(src/main/cpp/cpp_include)
#LINK_DIRECTORIES(src/main/cpp/cpp_lib)
add_library( websockets STATIC IMPORTED)
set_target_properties(websockets PROPERTIES IMPORTED_LOCATION src/main/cpp/cpp_lib/libwebsockets.a)
add_library( # Sets the name of the library.
#native-lib
SkylightWebSocket
# Sets the library as a shared library.
SHARED
# Provides a relative path to your source file(s).
#src/main/cpp/native-lib.cpp
${ALL_FILE})
find_library( # Sets the name of the path variable.
log-lib
# Specifies the name of the NDK library that
# you want CMake to locate.
log )
target_link_libraries( # Specifies the target library.
#native-lib
SkylightWebSocket
# Links the target library to the log library
# included in the NDK.
libwebsockets.a ${log-lib})
而不是 libwebsockets.a ,在target_link_libraries()
语句中使用 websockets 。
使其更容易理解,这是一个编辑的脚本:
add_library( Q STATIC IMPORTED)
set_target_properties(Q PROPERTIES IMPORTED_LOCATION src/main/cpp/cpp_lib/libwebsockets.a)
add_library( # Sets the name of the library.
#native-lib
SkylightWebSocket
# Sets the library as a shared library.
SHARED
# Provides a relative path to your source file(s).
#src/main/cpp/native-lib.cpp
${ALL_FILE})
target_link_libraries( # Specifies the target library.
#native-lib
SkylightWebSocket
# Links the target library to the log library
# included in the NDK.
Q log)
请注意,使用NDK, log 库是定义的,您根本不需要find_library
。
相关文章:
- 运行同一解决方案的另一个项目的项目
- Project Euler问题4的错误解决方案
- Ardunio UNO解决了多个重叠的定时器循环
- 函数何时会在c++中包含stack_Unwind_Resume调用
- 如何解决gcc编译器优化导致的centos双编译器设置中的分段错误
- 如何指定我希望我的LIB链接到的DLL文件?-Visual Studio 2019
- 两个文件使用彼此的功能-如何解决
- Android Studio使用JNI来构建C/C ,但是C/C 需要另一个lib.a,如何解决
- MSVS 2015构建DLL-在MSVCRTD.LIB(EXE_MAIN.OBJ)中的Indoke_main中未解决的外
- 未解决的外部符号,带有静态lib,它使用了另一个静态lib
- 将 DLL 链接到 LIB 的未解决的外部符号错误
- "/usr/lib/libstdc .so.6: version `GLIBCXX_3.4.15' not found"是什么意思,我该如何解决?
- "/usr/lib/libstdc++.so.6: version `GLIBCXX_3.4.15' not found`",如何解决?
- lib(发布)或libd(调试),可以为我解决这个问题
- curllib_static.lib错误LNK2019:未解决的外部符号错误
- 是否有一个c++源/lib来解决2D Bin Packing使用矩形Bin(而不是正方形)和旋转
- 如何解决由于在Visual Studio中向c++项目添加.lib文件而导致的链接错误
- 解决 VC++ 中的 hid.lib "unresolved external symbol"链接器错误
- 链接器如何解决链接*.lib时的歧义
- C++Visual Studio-多项目解决方案-“;静态lib”;vs“;包括目录”;