简体   繁体   English

CMake测试被忽略-在Android中使用Gradle构建CMake项目

[英]Cmake test gets ignored - building cmake project with gradle in android

I'm trying to integrate https://github.com/j0r1/JRTPLIB into gradle. 我正在尝试将https://github.com/j0r1/JRTPLIB集成到gradle中。 There's already a tutorial on the readme about how to compile the library to installation on Android, but I need gradle integration. 自述文件中已经有一个有关如何编译该库以在Android上进行安装的教程,但是我需要gradle集成。

Here's how I added the project to my gradle file: 这是我将项目添加到gradle文件中的方法:

https://github.com/lucaszanella/jscam/blob/ecc99f430b360f7e1aa5bf687633a5e3557c045e/src/jscam/android/app/build.gradle#L118 https://github.com/lucaszanella/jscam/blob/ecc99f430b360f7e1aa5bf687633a5e3557c045e/src/jscam/android/app/build.gradle#L118

I'm getting a compilation error because my system libs don't have support for ifaddrs . 我收到编译错误,因为我的系统库不支持ifaddrs However, the cmakelists of the project has a test for that: 但是,该项目的cmakelist对此进行了测试:

jrtplib_include_test(ifaddrs.h RTP_SUPPORT_IFADDRS "// No ifaddrs support")

So why is gradle trying to build something that didn't pass the test? 那么,为什么gradle试图构建未通过测试的东西?

Here's the error while compiling my app: 这是编译我的应用程序时的错误:

Error while executing '/android-sdk-linux/cmake/3.6.4111459/bin/cmake' with arguments {--build /home/project/src/jscam/android/app/.externalNativeBuild/cmake/debug/x86 --target jrtplib-shared}
  [1/3] Building CXX object src/CMakeFiles/jrtplib-shared.dir/rtpudpv4transmitter.cpp.o
  [2/3] Building CXX object src/CMakeFiles/jrtplib-shared.dir/rtpudpv6transmitter.cpp.o
  FAILED: /android-sdk-linux/ndk-bundle/toolchains/llvm/prebuilt/linux-x86_64/bin/clang++  --target=i686-none-linux-android --gcc-toolchain=/android-sdk-linux/ndk-bundle/toolchains/x86-4.9/prebuilt/linux-x86_64 --sysroot=/android-sdk-linux/ndk-bundle/sysroot  -DJRTPLIB_COMPILING -Djrtplib_shared_EXPORTS -I/home/project/src/jscam/JRTPLIB/src -Isrc -isystem /android-sdk-linux/ndk-bundle/sources/cxx-stl/gnu-libstdc++/4.9/include -isystem /android-sdk-linux/ndk-bundle/sources/cxx-stl/gnu-libstdc++/4.9/libs/x86/include -isystem /android-sdk-linux/ndk-bundle/sources/cxx-stl/gnu-libstdc++/4.9/include/backward-isystem /android-sdk-linux/ndk-bundle/sysroot/usr/include/i686-linux-android -D__ANDROID_API__=16 -g -DANDROID -ffunction-sections -funwind-tables -fstack-protector-strong -no-canonical-prefixes -mstackrealign -Wa,--noexecstack -Wformat -Werror=format-security   -O0 -fno-limit-debug-info  -fPIC -MD -MT src/CMakeFiles/jrtplib-shared.dir/rtpudpv6transmitter.cpp.o -MF src/CMakeFiles/jrtplib-shared.dir/rtpudpv6transmitter.cpp.o.d -o src/CMakeFiles/jrtplib-shared.dir/rtpudpv6transmitter.cpp.o -c /home/project/src/jscam/JRTPLIB/src/rtpudpv6transmitter.cpp
  /home/project/src/jscam/JRTPLIB/src/rtpudpv6transmitter.cpp:1575:2: error: use of undeclared identifier 'getifaddrs'
          getifaddrs(&addrs);
          ^
  /home/project/src/jscam/JRTPLIB/src/rtpudpv6transmitter.cpp:1588:2: error: use of undeclared identifier 'freeifaddrs'
          freeifaddrs(addrs);
          ^
  2 errors generated.
  FAILED: /android-sdk-linux/ndk-bundle/toolchains/llvm/prebuilt/linux-x86_64/bin/clang++  --target=i686-none-linux-android --gcc-toolchain=/android-sdk-linux/ndk-bundle/toolchains/x86-4.9/prebuilt/linux-x86_64 --sysroot=/android-sdk-linux/ndk-bundle/sysroot  -DJRTPLIB_COMPILING -Djrtplib_shared_EXPORTS -I/home/project/src/jscam/JRTPLIB/src -Isrc -isystem /android-sdk-linux/ndk-bundle/sources/cxx-stl/gnu-libstdc++/4.9/include -isystem /android-sdk-linux/ndk-bundle/sources/cxx-stl/gnu-libstdc++/4.9/libs/x86/include -isystem /android-sdk-linux/ndk-bundle/sources/cxx-stl/gnu-libstdc++/4.9/include/backward-isystem /android-sdk-linux/ndk-bundle/sysroot/usr/include/i686-linux-android -D__ANDROID_API__=16 -g -DANDROID -ffunction-sections -funwind-tables -fstack-protector-strong -no-canonical-prefixes -mstackrealign -Wa,--noexecstack -Wformat -Werror=format-security   -O0 -fno-limit-debug-info  -fPIC -MD -MT src/CMakeFiles/jrtplib-shared.dir/rtpudpv4transmitter.cpp.o -MF src/CMakeFiles/jrtplib-shared.dir/rtpudpv4transmitter.cpp.o.d -o src/CMakeFiles/jrtplib-shared.dir/rtpudpv4transmitter.cpp.o -c /home/project/src/jscam/JRTPLIB/src/rtpudpv4transmitter.cpp
  /home/project/src/jscam/JRTPLIB/src/rtpudpv4transmitter.cpp:1813:2: error: use of undeclared identifier 'getifaddrs'
          getifaddrs(&addrs);
          ^
  /home/project/src/jscam/JRTPLIB/src/rtpudpv4transmitter.cpp:1826:2: error: use of undeclared identifier 'freeifaddrs'
          freeifaddrs(addrs);
          ^
  2 errors generated.
  ninja: build stopped: subcommand failed.

Android NDK has <ifaddrs.h> for you. Android NDK为您提供了<ifaddrs.h> But the missing functions, like getifaddrs() , are available for __ANDROID_API__ 24 and higher, while your projects sets __ANDROID_API__=16 . 但是缺少的功能(如getifaddrs())可用于__ANDROID_API__ 24及更高版本,而您的项目设置__ANDROID_API __ = 16

If your library will be used with minSdkVersion below 24, you cannot use these functions. 如果您的库使用的minSdkVersion低于24,则不能使用这些功能。 Unfortunately, JRTPLIB doesn't seem to have such granular support for ifaddrs, but you can force RTP_SUPPORT_IFADDRS off if you choose to. 不幸的是,JRPTPLIB似乎对ifaddrs没有这么细致的支持,但是如果您愿意,可以强制关闭RTP_SUPPORT_IFADDRS

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM