mediaNdk undefined reference to 'AMediaCodec_signalEndOfInputStream' - android

can not find AMediaCodec_signalEndOfInputStream on link process.
ExportThread.cpp source
configure file
apilevel android-21
here is my config
CmakeLists.txt
target_link_libraries(${Lib_Name}
android
mediandk
EGL
GLESv3
log )
gradle.build
ndk {
abiFilters 'armeabi-v7a'
// , 'armeabi-v7a', 'arm64-v8a'
}
externalNativeBuild {
cmake {
arguments '-DANDROID_PLATFORM=android-21'
}
}
errors
[35/35] Linking CXX shared library /Users/rqg/ASProjects/PboTest/muses/build/intermediates/cmake/debug/obj/armeabi-v7a/libnative-lib.so
FAILED: : && /Users/rqg/Library/Android/sdk/ndk-bundle/toolchains/llvm/prebuilt/darwin-x86_64/bin/clang++ --target=armv7-none-linux-androideabi --gcc-toolchain=/Users/rqg/Library/Android/sdk/ndk-bundle/toolchains/arm-linux-androideabi-4.9/prebuilt/darwin-x86_64 --sysroot=/Users/rqg/Library/Android/sdk/ndk-bundle/sysroot -fPIC -isystem /Users/rqg/Library/Android/sdk/ndk-bundle/sysroot/usr/include/arm-linux-androideabi -D__ANDROID_API__=21 -g -DANDROID -ffunction-sections -funwind-tables -fstack-protector-strong -no-canonical-prefixes -march=armv7-a -mfloat-abi=softfp -mfpu=vfpv3-d16 -fno-integrated-as -mthumb -Wa,--noexecstack -Wformat -Werror=format-security -std=c++11 -frtti -fexceptions -Wall -O0 -fno-limit-debug-info -Wl,--exclude-libs,libgcc.a --sysroot /Users/rqg/Library/Android/sdk/ndk-bundle/platforms/android-21/arch-arm -Wl,--build-id -Wl,--warn-shared-textrel -Wl,--fatal-warnings -Wl,--fix-cortex-a8 -Wl,--no-undefined -Wl,-z,noexecstack -Qunused-arguments -Wl,-z,relro -Wl,-z,now -shared -Wl,-soname,libnative-lib.so -o /Users/rqg/ASProjects/PboTest/muses/build/intermediates/cmake/debug/obj/armeabi-v7a/libnative-lib.so CMakeFiles/native-lib.dir/DecodeThread.cpp.o CMakeFiles/native-lib.dir/DelayThread.cpp.o CMakeFiles/native-lib.dir/EffectLine.cpp.o CMakeFiles/native-lib.dir/EffectManager.cpp.o CMakeFiles/native-lib.dir/ExportThread.cpp.o CMakeFiles/native-lib.dir/NativeSurfaceTexture.cpp.o CMakeFiles/native-lib.dir/Painter.cpp.o CMakeFiles/native-lib.dir/PboPool.cpp.o CMakeFiles/native-lib.dir/Player.cpp.o CMakeFiles/native-lib.dir/PrepareThread.cpp.o CMakeFiles/native-lib.dir/RenderManager.cpp.o CMakeFiles/native-lib.dir/RenderTask.cpp.o CMakeFiles/native-lib.dir/effect/BlurEffect.cpp.o CMakeFiles/native-lib.dir/effect/BoostEffect.cpp.o CMakeFiles/native-lib.dir/effect/ChaplinEffect.cpp.o CMakeFiles/native-lib.dir/effect/Effect.cpp.o CMakeFiles/native-lib.dir/effect/FadeEffect.cpp.o CMakeFiles/native-lib.dir/effect/NormalEffect.cpp.o CMakeFiles/native-lib.dir/framesource/IFrameSource.cpp.o CMakeFiles/native-lib.dir/framesource/ImageFrameSource.cpp.o CMakeFiles/native-lib.dir/framesource/VideoFrameSource.cpp.o CMakeFiles/native-lib.dir/gl/EglCore.cpp.o CMakeFiles/native-lib.dir/gl/surface/EglSurfaceBase.cpp.o CMakeFiles/native-lib.dir/gl/surface/OffscreenSurface.cpp.o CMakeFiles/native-lib.dir/gl/surface/WindowSurface.cpp.o CMakeFiles/native-lib.dir/native-lib.cpp.o CMakeFiles/native-lib.dir/render/BlurRender.cpp.o CMakeFiles/native-lib.dir/render/FadeRender.cpp.o CMakeFiles/native-lib.dir/render/NormalRender.cpp.o CMakeFiles/native-lib.dir/render/PolygonOffsetRenderer.cpp.o CMakeFiles/native-lib.dir/render/Render.cpp.o CMakeFiles/native-lib.dir/util/DelayLooper.cpp.o CMakeFiles/native-lib.dir/util/Looper.cpp.o CMakeFiles/native-lib.dir/util/common.cpp.o -landroid -lmediandk -lEGL -lGLESv3 -llog -lm "/Users/rqg/Library/Android/sdk/ndk-bundle/sources/cxx-stl/gnu-libstdc++/4.9/libs/armeabi-v7a/libgnustl_static.a" && :
/Users/rqg/ASProjects/PboTest/muses/src/main/cpp/ExportThread.cpp:37: error: undefined reference to 'AMediaCodec_signalEndOfInputStream'
/Users/rqg/ASProjects/PboTest/muses/src/main/cpp/ExportThread.cpp:107: error: undefined reference to 'AMediaCodec_createInputSurface'
clang++: error: linker command failed with exit code 1 (use -v to see invocation)
ninja: build stopped: subcommand failed.

This is a bug in NDK r.15. This API was only introduced in android-26. BTW, you can rely on Android Studio to set -DANDROID_PLATFORM to correspond to minSdkVersion as chosen in build.gradle.

Related

OpenCV Android Linking CXX shared library FAILED

I'm trying to build a VINS app on android platform, and I'm facing some library linking error. Seems it could not find gomp, but it's included in the target target_link_libraries in the CMakeLists.txt.
Could anyone provide me any hints on solving this problem? Many thanks!
Execution failed for task ':app:buildCMakeRelease'.
> Build command failed.
Error while executing process /Users/sue/Library/Android/sdk/cmake/3.10.2.4988404/bin/ninja with arguments {-C /Users/sue/Documents/Vins-On-Android-master4/Vins-Droidcv310/app/.cxx/Release/l4h4jp5k/arm64-v8a native-lib}
ninja: Entering directory `/Users/sue/Documents/Vins-On-Android-master4/Vins-Droidcv310/app/.cxx/Release/l4h4jp5k/arm64-v8a'
[1/1] Linking CXX shared library ../../../../build/intermediates/cxx/Release/l4h4jp5k/obj/arm64-v8a/libnative-lib.so
FAILED: ../../../../build/intermediates/cxx/Release/l4h4jp5k/obj/arm64-v8a/libnative-lib.so
: && /Users/sue/Library/Android/sdk/ndk/18.1.5063045/toolchains/llvm/prebuilt/darwin-x86_64/bin/clang++ --target=aarch64-none-linux-android21 --gcc-toolchain=/Users/sue/Library/Android/sdk/ndk/18.1.5063045/toolchains/aarch64-linux-android-4.9/prebuilt/darwin-x86_64 --sysroot=/Users/sue/Library/Android/sdk/ndk/18.1.5063045/sysroot -fPIC -isystem /Users/sue/Library/Android/sdk/ndk/18.1.5063045/sysroot/usr/include/aarch64-linux-android -g -DANDROID -ffunction-sections -funwind-tables -fstack-protector-strong -no-canonical-prefixes -Wa,--noexecstack -Wformat -Werror=format-security -std=c++11 -frtti -fexceptions -std=c++0x -O2 -DNDEBUG -Wl,--exclude-libs,libgcc.a -Wl,--exclude-libs,libatomic.a -nostdlib++ --sysroot /Users/sue/Library/Android/sdk/ndk/18.1.5063045/platforms/android-21/arch-arm64 -Wl,--build-id -Wl,--warn-shared-textrel -Wl,--fatal-warnings -L/Users/sue/Library/Android/sdk/ndk/18.1.5063045/sources/cxx-stl/llvm-libc++/libs/arm64-v8a -Wl,--no-undefined -Wl,-z,noexecstack -Qunused-arguments -Wl,-z,relro -Wl,-z,now -shared -Wl,-soname,libnative-lib.so -o ../../../../build/intermediates/cxx/Release/l4h4jp5k/obj/arm64-v8a/libnative-lib.so CMakeFiles/native-lib.dir/src/main/cpp/native-lib.cpp.o CMakeFiles/native-lib.dir/src/main/cpp/src/vins_estimator/src/estimator_node.cpp.o CMakeFiles/native-lib.dir/src/main/cpp/src/vins_estimator/src/parameters.cpp.o CMakeFiles/native-lib.dir/src/main/cpp/src/vins_estimator/src/estimator.cpp.o CMakeFiles/native-lib.dir/src/main/cpp/src/vins_estimator/src/feature_manager.cpp.o CMakeFiles/native-lib.dir/src/main/cpp/src/vins_estimator/src/factor/pose_local_parameterization.cpp.o CMakeFiles/native-lib.dir/src/main/cpp/src/vins_estimator/src/factor/projection_factor.cpp.o CMakeFiles/native-lib.dir/src/main/cpp/src/vins_estimator/src/factor/marginalization_factor.cpp.o CMakeFiles/native-lib.dir/src/main/cpp/src/vins_estimator/src/utility/utility.cpp.o CMakeFiles/native-lib.dir/src/main/cpp/src/vins_estimator/src/utility/visualization.cpp.o CMakeFiles/native-lib.dir/src/main/cpp/src/vins_estimator/src/initial/solve_5pts.cpp.o CMakeFiles/native-lib.dir/src/main/cpp/src/vins_estimator/src/initial/initial_aligment.cpp.o CMakeFiles/native-lib.dir/src/main/cpp/src/vins_estimator/src/initial/initial_sfm.cpp.o CMakeFiles/native-lib.dir/src/main/cpp/src/vins_estimator/src/initial/initial_ex_rotation.cpp.o CMakeFiles/native-lib.dir/src/main/cpp/src/vins_estimator/src/loop-closure/ThirdParty/DBoW/BowVector.cpp.o CMakeFiles/native-lib.dir/src/main/cpp/src/vins_estimator/src/loop-closure/ThirdParty/DBoW/FBrief.cpp.o CMakeFiles/native-lib.dir/src/main/cpp/src/vins_estimator/src/loop-closure/ThirdParty/DBoW/FeatureVector.cpp.o CMakeFiles/native-lib.dir/src/main/cpp/src/vins_estimator/src/loop-closure/ThirdParty/DBoW/QueryResults.cpp.o CMakeFiles/native-lib.dir/src/main/cpp/src/vins_estimator/src/loop-closure/ThirdParty/DBoW/ScoringObject.cpp.o CMakeFiles/native-lib.dir/src/main/cpp/src/vins_estimator/src/loop-closure/ThirdParty/DUtils/Random.cpp.o CMakeFiles/native-lib.dir/src/main/cpp/src/vins_estimator/src/loop-closure/ThirdParty/DUtils/Timestamp.cpp.o CMakeFiles/native-lib.dir/src/main/cpp/src/vins_estimator/src/loop-closure/ThirdParty/DVision/BRIEF.cpp.o CMakeFiles/native-lib.dir/src/main/cpp/src/vins_estimator/src/loop-closure/ThirdParty/VocabularyBinary.cpp.o CMakeFiles/native-lib.dir/src/main/cpp/src/vins_estimator/src/loop-closure/loop_closure.cpp.o CMakeFiles/native-lib.dir/src/main/cpp/src/vins_estimator/src/loop-closure/keyframe.cpp.o CMakeFiles/native-lib.dir/src/main/cpp/src/vins_estimator/src/loop-closure/keyframe_database.cpp.o CMakeFiles/native-lib.dir/src/main/cpp/src/vins_estimator/src/feature_tracker/feature_tracker.cpp.o CMakeFiles/native-lib.dir/src/main/cpp/src/camera_model/src/chessboard/Chessboard.cc.o CMakeFiles/native-lib.dir/src/main/cpp/src/camera_model/src/calib/CameraCalibration.cc.o CMakeFiles/native-lib.dir/src/main/cpp/src/camera_model/src/camera_models/Camera.cc.o CMakeFiles/native-lib.dir/src/main/cpp/src/camera_model/src/camera_models/CameraFactory.cc.o CMakeFiles/native-lib.dir/src/main/cpp/src/camera_model/src/camera_models/CostFunctionFactory.cc.o CMakeFiles/native-lib.dir/src/main/cpp/src/camera_model/src/camera_models/PinholeCamera.cc.o CMakeFiles/native-lib.dir/src/main/cpp/src/camera_model/src/camera_models/CataCamera.cc.o CMakeFiles/native-lib.dir/src/main/cpp/src/camera_model/src/camera_models/EquidistantCamera.cc.o CMakeFiles/native-lib.dir/src/main/cpp/src/camera_model/src/camera_models/ScaramuzzaCamera.cc.o CMakeFiles/native-lib.dir/src/main/cpp/src/camera_model/src/sparse_graph/Transform.cc.o CMakeFiles/native-lib.dir/src/main/cpp/src/camera_model/src/gpl/gpl.cc.o CMakeFiles/native-lib.dir/src/main/cpp/src/camera_model/src/gpl/EigenQuaternionParameterization.cc.o CMakeFiles/native-lib.dir/src/main/cpp/src/a2ir/log_util.cpp.o CMakeFiles/native-lib.dir/src/main/cpp/src/a2ir/phone_sensor.cpp.o CMakeFiles/native-lib.dir/src/main/cpp/src/a2ir/timer.cpp.o CMakeFiles/native-lib.dir/src/main/cpp/src/vins_estimator/src/draw_result/delaunay.cpp.o CMakeFiles/native-lib.dir/src/main/cpp/src/vins_estimator/src/draw_result/draw_result.cpp.o CMakeFiles/native-lib.dir/src/main/cpp/src/vins_estimator/src/draw_result/triangle.cpp.o ../../../../src/main/jniLibs/arm64-v8a/libopencv_java3.so ../../../../src/main/jniLibs/arm64-v8a/libopencv_calib3d.a ../../../../src/main/jniLibs/arm64-v8a/libopencv_core.a ../../../../src/main/jniLibs/arm64-v8a/libopencv_features2d.a ../../../../src/main/jniLibs/arm64-v8a/libopencv_flann.a ../../../../src/main/jniLibs/arm64-v8a/libopencv_highgui.a ../../../../src/main/jniLibs/arm64-v8a/libopencv_imgcodecs.a ../../../../src/main/jniLibs/arm64-v8a/libopencv_imgproc.a ../../../../src/main/jniLibs/arm64-v8a/libopencv_ml.a ../../../../src/main/jniLibs/arm64-v8a/libopencv_objdetect.a ../../../../src/main/jniLibs/arm64-v8a/libopencv_photo.a ../../../../src/main/jniLibs/arm64-v8a/libopencv_shape.a ../../../../src/main/jniLibs/arm64-v8a/libopencv_stitching.a ../../../../src/main/jniLibs/arm64-v8a/libopencv_superres.a ../../../../src/main/jniLibs/arm64-v8a/libopencv_ts.a ../../../../src/main/jniLibs/arm64-v8a/libopencv_video.a ../../../../src/main/jniLibs/arm64-v8a/libopencv_videoio.a ../../../../src/main/jniLibs/arm64-v8a/libopencv_videostab.a ../../../../src/main/jniLibs/arm64-v8a/libceres.a ../../../../src/main/jniLibs/arm64-v8a/libboost_filesystem-gcc-mt-1_53.a ../../../../src/main/jniLibs/arm64-v8a/libboost_program_options-gcc-mt-1_53.a ../../../../src/main/jniLibs/arm64-v8a/libboost_system-gcc-mt-1_53.a -landroid -llog -lgomp -latomic -lm "/Users/sue/Library/Android/sdk/ndk/18.1.5063045/sources/cxx-stl/llvm-libc++/libs/arm64-v8a/libc++_shared.so" && :
/Users/sue/Library/Android/sdk/ndk/18.1.5063045/toolchains/aarch64-linux-android-4.9/prebuilt/darwin-x86_64/lib/gcc/aarch64-linux-android/4.9.x/../../../../aarch64-linux-android/bin/ld: cannot find -lgomp
clang++: error: linker command failed with exit code 1 (use -v to see invocation)
ninja: build stopped: subcommand failed.
I downloaded a libceres.a from others and put into the jinLibs in the project, then I'm facing the error of Linking CXX shared library.

Failed to build ics-openvpn in Windows 10

I am try to build ics-openvpn on Windows 10 by Android Studio 4.2.1. I have installed cmake, ndk and sdk and successfully run the first gradle build (Sync project with gradle files). Unfortunately, I am not able to build the main. Below are the logs. It seems it is trying to copy the missing files cmake\skeletonDebug\obj\armeabi-v7a\nopie_openvpn.armeabi-v7a.
And, it is also missing "asio.hpp". Where could I find these files?
> Android Version 11
> Version of the app 0.7.22
Error 1:
[1031/1039] Linking C executable C:\Users\project-user\Desktop\ics-openvpn-0.7.22\main\build\intermediates\cmake\skeletonDebug\obj\armeabi-v7a\pie_openvpn.armeabi-v7a
FAILED: C:/Users/project-user/Desktop/ics-openvpn-0.7.22/main/build/intermediates/cmake/skeletonDebug/obj/armeabi-v7a/pie_openvpn.armeabi-v7a
cmd.exe /C "cd . && C:\Users\project-user\AppData\Local\Android\Sdk\ndk\21.4.7075529\toolchains\llvm\prebuilt\windows-x86_64\bin\clang.exe --target=armv7-none-linux-androideabi16 --gcc-toolchain=C:/Users/project-user/AppData/Local/Android/Sdk/ndk/21.4.7075529/toolchains/llvm/prebuilt/windows-x86_64 --sysroot=C:/Users/project-user/AppData/Local/Android/Sdk/ndk/21.4.7075529/toolchains/llvm/prebuilt/windows-x86_64/sysroot -g -DANDROID -fdata-sections -ffunction-sections -funwind-tables -fstack-protector-strong -no-canonical-prefixes -D_FORTIFY_SOURCE=2 -march=armv7-a -mthumb -Wformat -Werror=format-security -O0 -fno-limit-debug-info -Wl,--exclude-libs,libgcc.a -Wl,--exclude-libs,libgcc_real.a -Wl,--exclude-libs,libatomic.a -static-libstdc++ -Wl,--build-id -Wl,--fatal-warnings -Wl,--exclude-libs,libunwind.a -Wl,--no-undefined -Qunused-arguments -Wl,--gc-sections CMakeFiles/pie_openvpn.armeabi-v7a.dir/minivpn/minivpn.c.o -o C:\Users\project-user\Desktop\ics-openvpn-0.7.22\main\build\intermediates\cmake\skeletonDebug\obj\armeabi-v7a\pie_openvpn.armeabi-v7a C:/Users/project-user/Desktop/ics-openvpn-0.7.22/main/build/intermediates/cmake/skeletonDebug/obj/armeabi-v7a/libopenvpn.so -fPIE -pie libssl.a libcrypto.a liblzo.a -latomic -lm && cmd.exe /C "cd /D C:\Users\project-user\Desktop\ics-openvpn-0.7.22\main\.cxx\cmake\skeletonDebug\armeabi-v7a && C:\Users\project-user\AppData\Local\Android\Sdk\cmake\3.10.2.4988404\bin\cmake.exe -E copy C:/Users/project-user/Desktop/ics-openvpn-0.7.22/main/.cxx/cmake/skeletonDebug/armeabi-v7a/pie_openvpn.armeabi-v7a C:/Users/project-user/Desktop/ics-openvpn-0.7.22/main/src/main/cpp/../../../build/ovpnassets""
Error copying file "C:/Users/project-user/Desktop/ics-openvpn-0.7.22/main/.cxx/cmake/skeletonDebug/armeabi-v7a/pie_openvpn.armeabi-v7a" to "C:/Users/project-user/Desktop/ics-openvpn-0.7.22/main/src/main/cpp/../../../build/ovpnassets".
[1032/1039] Linking C executable C:\Users\project-user\Desktop\ics-openvpn-0.7.22\main\build\intermediates\cmake\skeletonDebug\obj\armeabi-v7a\nopie_openvpn.armeabi-v7a
FAILED: C:/Users/project-user/Desktop/ics-openvpn-0.7.22/main/build/intermediates/cmake/skeletonDebug/obj/armeabi-v7a/nopie_openvpn.armeabi-v7a
cmd.exe /C "cd . && C:\Users\project-user\AppData\Local\Android\Sdk\ndk\21.4.7075529\toolchains\llvm\prebuilt\windows-x86_64\bin\clang.exe --target=armv7-none-linux-androideabi16 --gcc-toolchain=C:/Users/project-user/AppData/Local/Android/Sdk/ndk/21.4.7075529/toolchains/llvm/prebuilt/windows-x86_64 --sysroot=C:/Users/project-user/AppData/Local/Android/Sdk/ndk/21.4.7075529/toolchains/llvm/prebuilt/windows-x86_64/sysroot -g -DANDROID -fdata-sections -ffunction-sections -funwind-tables -fstack-protector-strong -no-canonical-prefixes -D_FORTIFY_SOURCE=2 -march=armv7-a -mthumb -Wformat -Werror=format-security -O0 -fno-limit-debug-info -Wl,--exclude-libs,libgcc.a -Wl,--exclude-libs,libgcc_real.a -Wl,--exclude-libs,libatomic.a -static-libstdc++ -Wl,--build-id -Wl,--fatal-warnings -Wl,--exclude-libs,libunwind.a -Wl,--no-undefined -Qunused-arguments -Wl,--gc-sections CMakeFiles/nopie_openvpn.armeabi-v7a.dir/minivpn/minivpn.c.o -o C:\Users\project-user\Desktop\ics-openvpn-0.7.22\main\build\intermediates\cmake\skeletonDebug\obj\armeabi-v7a\nopie_openvpn.armeabi-v7a C:/Users/project-user/Desktop/ics-openvpn-0.7.22/main/build/intermediates/cmake/skeletonDebug/obj/armeabi-v7a/libopenvpn.so libssl.a libcrypto.a liblzo.a -latomic -lm && cmd.exe /C "cd /D C:\Users\project-user\Desktop\ics-openvpn-0.7.22\main\.cxx\cmake\skeletonDebug\armeabi-v7a && C:\Users\project-user\AppData\Local\Android\Sdk\cmake\3.10.2.4988404\bin\cmake.exe -E copy C:/Users/project-user/Desktop/ics-openvpn-0.7.22/main/.cxx/cmake/skeletonDebug/armeabi-v7a/nopie_openvpn.armeabi-v7a C:/Users/project-user/Desktop/ics-openvpn-0.7.22/main/src/main/cpp/../../../build/ovpnassets""
Error copying file "C:/Users/project-user/Desktop/ics-openvpn-0.7.22/main/.cxx/cmake/skeletonDebug/armeabi-v7a/nopie_openvpn.armeabi-v7a" to "C:/Users/project-user/Desktop/ics-openvpn-0.7.22/main/src/main/cpp/../../../build/ovpnassets".
[1033/1039] Generating ovpncli_wrap.cxx
ninja: build stopped: subcommand failed.
Error 2:
[1038/1039] Building CXX object CMakeFiles/ovpn3.dir/openvpn3/client/ovpncli.cpp.o
FAILED: CMakeFiles/ovpn3.dir/openvpn3/client/ovpncli.cpp.o
C:\Users\project-user\AppData\Local\Android\Sdk\ndk\21.4.7075529\toolchains\llvm\prebuilt\windows-x86_64\bin\clang++.exe --target=armv7-none-linux-androideabi16 --gcc-toolchain=C:/Users/project-user/AppData/Local/Android/Sdk/ndk/21.4.7075529/toolchains/llvm/prebuilt/windows-x86_64 --sysroot=C:/Users/project-user/AppData/Local/Android/Sdk/ndk/21.4.7075529/toolchains/llvm/prebuilt/windows-x86_64/sysroot -DASIO_STANDALONE -DGIT_VERSION_STRING=\"GIT-NOTFOUND\" -DHAVE_CONFIG_H -DHAVE_LZ4 -DHAVE_LZO -DNO_ROUTE_EXCLUDE_EMULATION -DOPENSSL_API_COMPAT=0x10200000L -DOPENVPN_SHOW_SESSION_TOKEN -DUSE_ASIO -DUSE_OPENSSL -Dovpn3_EXPORTS -IC:/Users/project-user/Desktop/ics-openvpn-0.7.22/main/src/main/cpp/lzo/include -IC:/Users/project-user/Desktop/ics-openvpn-0.7.22/main/src/main/cpp/openvpn3 -IC:/Users/project-user/Desktop/ics-openvpn-0.7.22/main/src/main/cpp/asio/asio/include -IC:/Users/project-user/Desktop/ics-openvpn-0.7.22/main/src/main/cpp/openvpn3/client -IC:/Users/project-user/Desktop/ics-openvpn-0.7.22/main/src/main/cpp/mbedtls/include -IC:/Users/project-user/Desktop/ics-openvpn-0.7.22/main/src/main/cpp/crypto/include -IC:/Users/project-user/Desktop/ics-openvpn-0.7.22/main/src/main/cpp/openssl/include -IC:/Users/project-user/Desktop/ics-openvpn-0.7.22/main/src/main/cpp/openssl/crypto/include -IC:/Users/project-user/Desktop/ics-openvpn-0.7.22/main/src/main/cpp/openssl -IC:/Users/project-user/Desktop/ics-openvpn-0.7.22/main/src/main/cpp/openssl/crypto -IC:/Users/project-user/Desktop/ics-openvpn-0.7.22/main/src/main/cpp/openssl/crypto/ec/curve448/arch_32 -IC:/Users/project-user/Desktop/ics-openvpn-0.7.22/main/src/main/cpp/openssl/crypto/ec/curve448 -IC:/Users/project-user/Desktop/ics-openvpn-0.7.22/main/src/main/cpp/openssl/providers/common/include -IC:/Users/project-user/Desktop/ics-openvpn-0.7.22/main/src/main/cpp/openssl/providers/implementations/include -IC:/Users/project-user/Desktop/ics-openvpn-0.7.22/main/src/main/cpp/lz4/lib -g -DANDROID -fdata-sections -ffunction-sections -funwind-tables -fstack-protector-strong -no-canonical-prefixes -D_FORTIFY_SOURCE=2 -march=armv7-a -mthumb -Wformat -Werror=format-security -O0 -fno-limit-debug-info -fPIC -std=c++1y -MD -MT CMakeFiles/ovpn3.dir/openvpn3/client/ovpncli.cpp.o -MF CMakeFiles\ovpn3.dir\openvpn3\client\ovpncli.cpp.o.d -o CMakeFiles/ovpn3.dir/openvpn3/client/ovpncli.cpp.o -c C:/Users/project-user/Desktop/ics-openvpn-0.7.22/main/src/main/cpp/openvpn3/client/ovpncli.cpp
In file included from C:/Users/project-user/Desktop/ics-openvpn-0.7.22/main/src/main/cpp/openvpn3/client/ovpncli.cpp:30:
C:/Users/project-user/Desktop/ics-openvpn-0.7.22/main/src/main/cpp/openvpn3\openvpn/io/io.hpp:28:10: fatal error: 'asio.hpp' file not found
#include <asio.hpp>
^~~~~~~~~~
1 error generated.
ninja: build stopped: subcommand failed.
Did you run git submodule update --init after cloning the repository?

Using std::bad_function_call with LIBCPP_ABI_UNSTABLE

I am trying to build a native library in my Android Studio project that uses the std::bad_function_call function.
Here's the CMakeLists.txt file I use to build my native module:
cmake_minimum_required(VERSION 3.4.1)
include_directories(src/main/cpp)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-rtti -D_LIBCPP_ABI_UNSTABLE")
add_library(
MyLib
SHARED
src/main/cpp/test.cpp
)
and my test.cpp contains the following code:
void SomeClass::SomeMethod() {
std::function<int()> f = nullptr;
try {
f();
} catch (const std::bad_function_call& e) {
}
}
with the corresponding build.gradle section:
externalNativeBuild {
cmake {
arguments "-DANDROID_TOOLCHAIN=clang", "-DANDROID_STL=c++_static", "-DANDROID_NDK_ROOT=${android.ndkDirectory}"
}
}
If I pass the _LIBCPP_ABI_UNSTABLE flag to the compiler I get a link error:
Execution failed for task ':runtime:externalNativeBuildRelease'.
> Build command failed.
Error while executing process C:\android-sdk\cmake\3.6.4111459\bin\cmake.exe with arguments {--build C:\work\android-runtime\test-app\runtime\.externalNativeBuild\cmake\release\armeabi-v7a --target MyLib}
[1/1] Linking CXX shared library ..\..\..\..\build\intermediates\cmake\release\obj\armeabi-v7a\libMyLib.so
FAILED: cmd.exe /C "cd . && C:\android-sdk\ndk-bundle\toolchains\llvm\prebuilt\windows-x86_64\bin\clang++.exe --target=armv7-none-linux-androideabi17 --gcc-toolchain=C:/android-sdk/ndk-bundle/toolchains/llvm/prebuilt/windows-x86_64 -fPIC --sysroot C:/android-sdk/ndk-bundle/toolchains/llvm/prebuilt/windows-x86_64/sysroot -g -DANDROID -fdata-sections -ffunction-sections -funwind-tables -fstack-protector-strong -no-canonical-prefixes -mfpu=vfpv3-d16 -fno-addrsig -mthumb -Wa,--noexecstack -Wformat -Werror=format-security -stdlib=libc++ -fno-rtti -D_LIBCPP_ABI_UNSTABLE -Oz -DNDEBUG -Wl,--exclude-libs,libgcc.a -Wl,--exclude-libs,libatomic.a -static-libstdc++ -Wl,--build-id -Wl,--warn-shared-textrel -Wl,--fatal-warnings -Wl,--exclude-libs,libunwind.a -Wl,--no-undefined -Qunused-arguments -Wl,-z,noexecstack -Wl,-z,relro -Wl,-z,now -shared -Wl,-soname,libMyLib.so -o ..\..\..\..\build\intermediates\cmake\release\obj\armeabi-v7a\libMyLib.so CMakeFiles/MyLib.dir/src/main/cpp/test.cpp.o ../../../../src/main/libs/armeabi-v7a/abc.a -llog -latomic -lm && cd ."
C:/android-sdk/ndk-bundle/toolchains/llvm/prebuilt/windows-x86_64/sysroot/usr/include/c++/v1/functional:0: error: undefined reference to 'vtable for std::__ndk1::bad_function_call'
C:/android-sdk/ndk-bundle/toolchains/llvm/prebuilt/windows-x86_64/lib/gcc/arm-linux-androideabi/4.9.x/../../../../arm-linux-androideabi/bin\ld: the vtable symbol may be undefined because the class is missing its key function
C:/android-sdk/ndk-bundle/toolchains/llvm/prebuilt/windows-x86_64/sysroot/usr/include/c++/v1/functional:0: error: undefined reference to 'std::__ndk1::bad_function_call::~bad_function_call()'
clang++.exe: error: linker command failed with exit code 1 (use -v to see invocation)
ninja: build stopped: subcommand failed.
If I remove the _LIBCPP_ABI_UNSTABLE flag:
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-rtti")
then the project compiles fine.
So my question is what would be the proper way to enable the libc++ unstable abi and use the bad_function_call method inside my native module?
Note: I am using Android NDK 19.

NDK Code Coverage

Does anybody enabled code coverage NDK build on Android?
by using cmake with the comments from this link code coverage for native code using Android NDK
I ended up with the same error:
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} --coverage -fprofile-arcs -ftest-coverage")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} --coverage -fprofile-arcs -ftest-coverage")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} --coverage -fprofile-arcs -ftest-coverage")
so I'm creating a new thread for asking this issue.
The "same error" from the other thread:
[3/3] Linking CXX shared library ../../../../build/intermediates/cmake/project/debug/obj/armeabi/libscanhwl_camif.so
FAILED: : && /home/user/tools/android-ndk-r14b/toolchains/llvm/prebuilt/linux-x86_64/bin/clang++ --target=armv5te-none-linux-androideabi --gcc-toolchain=/home/user/tools/android-ndk-r14b/toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64 --sysroot=/home/user/tools/android-ndk-r14b/sysroot -fPIC -isystem /home/user/tools/android-ndk-r14b/sysroot/usr/include/arm-linux-androideabi -D__ANDROID_API__=19 -g -DANDROID -ffunction-sections -funwind-tables -fstack-protector-strong -no-canonical-prefixes -march=armv5te -mtune=xscale -msoft-float -fno-integrated-as -mthumb -Wa,--noexecstack -Wformat -Werror=format-security -D__STDC_FORMAT_MACROS -fexceptions -frtti --coverage -fprofile-arcs -ftest-coverage -O0 -fno-limit-debug-info -Wl,--exclude-libs,libgcc.a -Wl,--exclude-libs,libatomic.a --sysroot /home/user/tools/android-ndk-r14b/platforms/android-19/arch-arm -Wl,--build-id -Wl,--warn-shared-textrel -Wl,--fatal-warnings -Wl,--no-undefined -Wl,-z,noexecstack -Qunused-arguments -Wl,-z,relro -Wl,-z,now -shared -Wl,-soname,libscanhwl_camif.so -o -latomic -lm "/home/user/tools/android-ndk-r14b/sources/cxx-stl/gnu-libstdc++/4.9/libs/armeabi/libgnustl_static.a" && :
out/stage2/soong/ndk/sysroot/usr/include/string.h:348: error: undefined reference to '__strncpy_chk2'
clang++: error: linker command failed with exit code 1 (use -v to see invocation)
ninja: build stopped: subcommand failed.
Step one would be using a newer NDK (not sure which you're using, the other person was using r14b which is ancient). It looks like the coverage runtime library was built against a newer version of Android than you're using and so it can't be used usefully in the NDK. If you have the same issue in r17b, it's an NDK bug.
Note that coverage isn't something we really have support for right now, but it's on my todo list: https://github.com/android-ndk/ndk/issues/612.

Android Studio CMake error (clang.exe broken )

When I open a new project that support C++ in Android Studio, It only outputs "Hello C++",And I didn't modify any code. I have tried to change the version of Android Studio and SDK. But it always show the same error.
My development platform: Windows 10
Now version: Android Studio 3.1.2
Thank you very much
Error While Building:
Build command failed.
Error while executing process C:\Users\15829\AppData\Local\Android\Sdk\cmake\3.6.4111459\bin\cmake.exe with arguments {-HC:\Users\15829\AndroidStudioProjects\MyApplication\app -BC:\Users\15829\AndroidStudioProjects\MyApplication\app\.externalNativeBuild\cmake\debug\armeabi-v7a -DANDROID_ABI=armeabi-v7a -DANDROID_PLATFORM=android-15 -DCMAKE_LIBRARY_OUTPUT_DIRECTORY=C:\Users\15829\AndroidStudioProjects\MyApplication\app\build\intermediates\cmake\debug\obj\armeabi-v7a -DCMAKE_BUILD_TYPE=Debug -DANDROID_NDK=C:\Users\15829\AppData\Local\Android\Sdk\ndk-bundle -DCMAKE_CXX_FLAGS= -DCMAKE_TOOLCHAIN_FILE=C:\Users\15829\AppData\Local\Android\Sdk\ndk-bundle\build\cmake\android.toolchain.cmake -DCMAKE_MAKE_PROGRAM=C:\Users\15829\AppData\Local\Android\Sdk\cmake\3.6.4111459\bin\ninja.exe -GAndroid Gradle - Ninja}
-- Check for working C compiler: C:/Users/15829/AppData/Local/Android/Sdk/ndk-bundle/toolchains/llvm/prebuilt/windows-x86_64/bin/clang.exe
-- Check for working C compiler: C:/Users/15829/AppData/Local/Android/Sdk/ndk-bundle/toolchains/llvm/prebuilt/windows-x86_64/bin/clang.exe -- broken
/Users/15829/AppData/Local/Android/Sdk/ndk-bundle/toolchains/llvm/prebuilt/windows-x86_64/bin/clang.exe" is not able to compile a simple test program.
Open File
It fails with the following output:
Change Dir: C:/Users/15829/AndroidStudioProjects/MyApplication/app/.externalNativeBuild/cmake/debug/armeabi-v7a/CMakeFiles/CMakeTmp
Run Build
Command:"C:\Users\15829\AppData\Local\Android\Sdk\cmake\3.6.4111459\bin\ninja.exe"
"cmTC_a2146"
[1/2] Building C object CMakeFiles/cmTC_a2146.dir/testCCompiler.c.o
[2/2] Linking C executable cmTC_a2146
FAILED: cmd.exe /C "cd . &&
C:\Users\15829\AppData\Local\Android\Sdk\ndk-bundle\toolchains\llvm\prebuilt\windows-x86_64\bin\clang.exe
--target=armv7-none-linux-androideabi
--gcc-toolchain=C:/Users/15829/AppData/Local/Android/Sdk/ndk-bundle/toolchains/arm-linux-androideabi-4.9/prebuilt/windows-x86_64
--sysroot=C:/Users/15829/AppData/Local/Android/Sdk/ndk-bundle/sysroot
-isystem
C:/Users/15829/AppData/Local/Android/Sdk/ndk-bundle/sysroot/usr/include/arm-linux-androideabi
-D__ANDROID_API__=15 -g -DANDROID -ffunction-sections -funwind-tables
-fstack-protector-strong -no-canonical-prefixes -march=armv7-a
-mfloat-abi=softfp -mfpu=vfpv3-d16 -mthumb -Wa,--noexecstack -Wformat
-Werror=format-security -Wl,--exclude-libs,libgcc.a
-Wl,--exclude-libs,libatomic.a -nostdlib++ --sysroot
C:/Users/15829/AppData/Local/Android/Sdk/ndk-bundle/platforms/android-15/arch-arm
-Wl,--build-id -Wl,--warn-shared-textrel -Wl,--fatal-warnings
-Wl,--fix-cortex-a8 -Wl,--exclude-libs,libunwind.a
-LC:/Users/15829/AppData/Local/Android/Sdk/ndk-bundle/sources/cxx-stl/llvm-libc++/libs/armeabi-v7a
-Wl,--no-undefined -Wl,-z,noexecstack -Qunused-arguments -Wl,-z,relro
-Wl,-z,now -Wl,--gc-sections -Wl,-z,nocopyreloc
CMakeFiles/cmTC_a2146.dir/testCCompiler.c.o -o cmTC_a2146 -latomic -lm &&
cd ."
error: no such file or directory:
'CMakeFiles/cmTC_a2146.dir/testCCompiler.c.o'
ninja: build stopped: subcommand failed.
CMake will not be able to correctly generate this project.
Call Stack (most recent call first):
CMakeLists.txt
-- Configuring incomplete, errors occurred!
See also "C:/Users/15829/AndroidStudioProjects/MyApplication/app/.externalNativeBuild/cmake/debug/armeabi-v7a/CMakeFiles/CMakeOutput.log".
See also "C:/Users/15829/AndroidStudioProjects/MyApplication/app/.externalNativeBuild/cmake/debug/armeabi-v7a/CMakeFiles/CMakeError.log".
Build command failed.
Error while executing process C:\Users\15829\AppData\Local\Android\Sdk\cmake\3.6.4111459\bin\cmake.exe with arguments {-HC:\Users\15829\AndroidStudioProjects\MyApplication\app -BC:\Users\15829\AndroidStudioProjects\MyApplication\app\.externalNativeBuild\cmake\release\armeabi-v7a -DANDROID_ABI=armeabi-v7a -DANDROID_PLATFORM=android-15 -DCMAKE_LIBRARY_OUTPUT_DIRECTORY=C:\Users\15829\AndroidStudioProjects\MyApplication\app\build\intermediates\cmake\release\obj\armeabi-v7a -DCMAKE_BUILD_TYPE=Release -DANDROID_NDK=C:\Users\15829\AppData\Local\Android\Sdk\ndk-bundle -DCMAKE_CXX_FLAGS= -DCMAKE_TOOLCHAIN_FILE=C:\Users\15829\AppData\Local\Android\Sdk\ndk-bundle\build\cmake\android.toolchain.cmake -DCMAKE_MAKE_PROGRAM=C:\Users\15829\AppData\Local\Android\Sdk\cmake\3.6.4111459\bin\ninja.exe -GAndroid Gradle - Ninja}
-- Check for working C compiler: C:/Users/15829/AppData/Local/Android/Sdk/ndk-bundle/toolchains/llvm/prebuilt/windows-x86_64/bin/clang.exe
-- Check for working C compiler: C:/Users/15829/AppData/Local/Android/Sdk/ndk-bundle/toolchains/llvm/prebuilt/windows-x86_64/bin/clang.exe -- broken
/Users/15829/AppData/Local/Android/Sdk/ndk-bundle/toolchains/llvm/prebuilt/windows-x86_64/bin/clang.exe" is not able to compile a simple test program.
Open File
It fails with the following output:
Change Dir: C:/Users/15829/AndroidStudioProjects/MyApplication/app/.externalNativeBuild/cmake/release/armeabi-v7a/CMakeFiles/CMakeTmp
Run Build
Command:"C:\Users\15829\AppData\Local\Android\Sdk\cmake\3.6.4111459\bin\ninja.exe"
"cmTC_e2e33"
[1/2] Building C object CMakeFiles/cmTC_e2e33.dir/testCCompiler.c.o
[2/2] Linking C executable cmTC_e2e33
FAILED: cmd.exe /C "cd . &&
C:\Users\15829\AppData\Local\Android\Sdk\ndk-bundle\toolchains\llvm\prebuilt\windows-x86_64\bin\clang.exe
--target=armv7-none-linux-androideabi
--gcc-toolchain=C:/Users/15829/AppData/Local/Android/Sdk/ndk-bundle/toolchains/arm-linux-androideabi-4.9/prebuilt/windows-x86_64
--sysroot=C:/Users/15829/AppData/Local/Android/Sdk/ndk-bundle/sysroot
-isystem
C:/Users/15829/AppData/Local/Android/Sdk/ndk-bundle/sysroot/usr/include/arm-linux-androideabi
-D__ANDROID_API__=15 -g -DANDROID -ffunction-sections -funwind-tables
-fstack-protector-strong -no-canonical-prefixes -march=armv7-a
-mfloat-abi=softfp -mfpu=vfpv3-d16 -mthumb -Wa,--noexecstack -Wformat
-Werror=format-security -Wl,--exclude-libs,libgcc.a
-Wl,--exclude-libs,libatomic.a -nostdlib++ --sysroot
C:/Users/15829/AppData/Local/Android/Sdk/ndk-bundle/platforms/android-15/arch-arm
-Wl,--build-id -Wl,--warn-shared-textrel -Wl,--fatal-warnings
-Wl,--fix-cortex-a8 -Wl,--exclude-libs,libunwind.a
-LC:/Users/15829/AppData/Local/Android/Sdk/ndk-bundle/sources/cxx-stl/llvm-libc++/libs/armeabi-v7a
-Wl,--no-undefined -Wl,-z,noexecstack -Qunused-arguments -Wl,-z,relro
-Wl,-z,now -Wl,--gc-sections -Wl,-z,nocopyreloc
CMakeFiles/cmTC_e2e33.dir/testCCompiler.c.o -o cmTC_e2e33 -latomic -lm &&
cd ."
error: no such file or directory:
'CMakeFiles/cmTC_e2e33.dir/testCCompiler.c.o'
ninja: build stopped: subcommand failed.
CMake will not be able to correctly generate this project.
Call Stack (most recent call first):
CMakeLists.txt
-- Configuring incomplete, errors occurred!
See also "C:/Users/15829/AndroidStudioProjects/MyApplication/app/.externalNativeBuild/cmake/release/armeabi-v7a/CMakeFiles/CMakeOutput.log".
See also "C:/Users/15829/AndroidStudioProjects/MyApplication/app/.externalNativeBuild/cmake/release/armeabi-v7a/CMakeFiles/CMakeError.log".
Try to add this to your build.gradle:
externalNativeBuild {
cmake {
arguments '-DANDROID_TOOLCHAIN=clang' --> gcc
}
}

Categories

Resources