Created
October 25, 2017 11:29
-
-
Save Gopinathp/4fc523ec922117f2f3928eef2fb2e4fa to your computer and use it in GitHub Desktop.
Transient dependencies are bundled into the APK but not linked in the jni wrapper
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# | |
# Copyright (C) The Android Open Source Project | |
# | |
# Licensed under the Apache License, Version 2.0 (the "License"); | |
# you may not use this file except in compliance with the License. | |
# You may obtain a copy of the License at | |
# | |
# http://www.apache.org/licenses/LICENSE-2.0 | |
# | |
# Unless required by applicable law or agreed to in writing, software | |
# distributed under the License is distributed on an "AS IS" BASIS, | |
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
# See the License for the specific language governing permissions and | |
# limitations under the License. | |
# | |
cmake_minimum_required(VERSION 3.4.1) | |
set(CMAKE_SYSROOT "/Users/gopinath/Library/Android/sdk/ndk-bundle/platforms/android-16/arch-arm") | |
set (CMAKE_SHARED_LINKER_FLAGS "-Wl,--as-needed,-v") | |
# configure import libs | |
set(distribution_DIR ${CMAKE_SOURCE_DIR}/../../../../sharedlibs) | |
add_library(lib_ffmpeg SHARED IMPORTED) | |
set_target_properties(lib_ffmpeg PROPERTIES IMPORTED_LOCATION | |
${distribution_DIR}/ffmpeg/lib/armeabi/libavcodec.so) | |
# build application's shared lib | |
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=gnu++11") | |
add_library(ffmpeg-jni SHARED | |
tutorial02.c) | |
set(THREADS_PREFER_PTHREAD_FLAG ON) | |
find_package(Threads REQUIRED) | |
target_link_libraries(ffmpeg-jni Threads::Threads) | |
target_include_directories(ffmpeg-jni PRIVATE | |
${distribution_DIR}/ffmpeg/include | |
) | |
target_link_libraries(ffmpeg-jni | |
android | |
-ljnigraphics | |
lib_ffmpeg | |
log) |
Thanks Alex for taking time and identifying the newbie problems.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Two problems with your gist:
you should not override
CMAKE_SHARED_LINKER_FLAGS
for Android. If you badly need to, you can extend it:If you want to see verbose linker output, use
-v
without-Wl,
:If you keep the
CMAKE_SHARED_LINKER_FLAGS
that Android toolchain prepares for you, you get-Wl,--no-undefined
which will complain when it doesn't find'av_register_all'
, and it will set the path toplatforms/android-16/arch-arm
for you, so you don't need to set CMAKE_SYSROOT.