80,350
社区成员
发帖
与我相关
我的任务
分享
Build command failed.
Error while executing process /Users/mythwind/Library/Android/sdk/cmake/3.6.4111459/bin/cmake with arguments {--build /Users/mythwind/Learn/Android/democode/TestNdk/app/.externalNativeBuild/cmake/debug/armeabi-v7a --target native-lib}
[1/3] Building CXX object CMakeFiles/native-lib.dir/src/main/cpp/native-lib.cpp.o
[2/3] Building CXX object CMakeFiles/native-lib.dir/src/main/cpp/opengl/GLFilter.cpp.o
[3/3] Linking CXX shared library ../../../../build/intermediates/cmake/debug/obj/armeabi-v7a/libnative-lib.so
FAILED: : && /Users/mythwind/Library/Android/sdk/ndk-bundle/toolchains/llvm/prebuilt/darwin-x86_64/bin/clang++ --target=armv7-none-linux-androideabi23 --gcc-toolchain=/Users/mythwind/Library/Android/sdk/ndk-bundle/toolchains/arm-linux-androideabi-4.9/prebuilt/darwin-x86_64 --sysroot=/Users/mythwind/Library/Android/sdk/ndk-bundle/sysroot -fPIC -isystem /Users/mythwind/Library/Android/sdk/ndk-bundle/sysroot/usr/include/arm-linux-androideabi -g -DANDROID -ffunction-sections -funwind-tables -fstack-protector-strong -no-canonical-prefixes -march=armv7-a -mfloat-abi=softfp -mfpu=vfpv3-d16 -mthumb -mfpu=neon -Wa,--noexecstack -Wformat -Werror=format-security -std=c++11 -std=c++14 -std=c++11 -fno-rtti -fno-exceptions -Wall -O0 -fno-limit-debug-info -Wl,--exclude-libs,libgcc.a -Wl,--exclude-libs,libatomic.a -nostdlib++ --sysroot /Users/mythwind/Library/Android/sdk/ndk-bundle/platforms/android-23/arch-arm -Wl,--build-id -Wl,--warn-shared-textrel -Wl,--fatal-warnings -Wl,--fix-cortex-a8 -Wl,--exclude-libs,libunwind.a -L/Users/mythwind/Library/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 -shared -Wl,-soname,libnative-lib.so -o ../../../../build/intermediates/cmake/debug/obj/armeabi-v7a/libnative-lib.so CMakeFiles/native-lib.dir/src/main/cpp/native-lib.cpp.o CMakeFiles/native-lib.dir/src/main/cpp/opengl/GLFilter.cpp.o -lGLESv3 -llog -landroid -lEGL -llog -latomic -lm "/Users/mythwind/Library/Android/sdk/ndk-bundle/sources/cxx-stl/llvm-libc++/libs/armeabi-v7a/libc++_static.a" "/Users/mythwind/Library/Android/sdk/ndk-bundle/sources/cxx-stl/llvm-libc++/libs/armeabi-v7a/libc++abi.a" "/Users/mythwind/Library/Android/sdk/ndk-bundle/sources/cxx-stl/llvm-libc++/libs/armeabi-v7a/libunwind.a" "-ldl" && :
/Users/mythwind/Learn/Android/democode/TestNdk/app/src/main/cpp/native-lib.cpp:38: error: undefined reference to 'GLFilter::initFilter(_JNIEnv*, AAssetManager*)'
clang++: error: linker command failed with exit code 1 (use -v to see invocation)
ninja: build stopped: subcommand failed.
cmake_minimum_required(VERSION 3.4.1)
# Creates and names a library, sets it as either STATIC
# or SHARED, and provides the relative paths to its source code.
# You can define multiple libraries, and CMake builds them for you.
# Gradle automatically packages shared libraries with your APK.
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -fno-rtti -fno-exceptions -Wall")
if (${ANDROID_PLATFORM_LEVEL} LESS 12)
message(FATAL_ERROR "OpenGL 2 is not supported before API level 11 \
(currently using ${ANDROID_PLATFORM_LEVEL}).")
return()
elseif (${ANDROID_PLATFORM_LEVEL} LESS 18)
add_definitions("-DDYNAMIC_ES3")
#set(GL3STUB_SRC gl3stub.c)
set(OPENGL_LIB GLESv2)
else ()
set(OPENGL_LIB GLESv3)
endif (${ANDROID_PLATFORM_LEVEL} LESS 12)
file(GLOB native_srcs "src/main/cpp/*.cpp" "src/main/cpp/opengl/*.cpp")
add_library( # Sets the name of the library.
native-lib
# Sets the library as a shared library.
SHARED
# Provides a relative path to your source file(s).
${native_srcs}
)
# Searches for a specified prebuilt library and stores the path as a
# variable. Because CMake includes system libraries in the search path by
# default, you only need to specify the name of the public NDK library
# you want to add. CMake verifies that the library exists before
# completing its build.
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
android
)
# Specifies libraries CMake should link to your target library. You
# can link multiple libraries, such as libraries you define in this
# build script, prebuilt third-party libraries, or system libraries.
target_link_libraries( # Specifies the target library.
native-lib
${OPENGL_LIB}
# Links the target library to the log library
# included in the NDK.
${log-lib}
android
EGL
log
)
extern "C"
JNIEXPORT void JNICALL
Java_com_vincent_mythwind_testndk_ndk_JniInterface_nativeInit(
JNIEnv *env, jobject instance, jobject assetManager) {
AAssetManager *manager = AAssetManager_fromJava(env, assetManager);
if (manager == NULL) {
LOGE("=====jniinterface.AAssetManager is null");
return ;
}
if (mFilter) {
delete mFilter;
mFilter = NULL;
}
LOGE("======nativeInit: filter");
//mFilter->initGL(env, manager);
mFilter->initFilter(env, manager);
LOGE("======nativeInit");
}
#ifndef TESTNDK_GLFILTER_H
#define TESTNDK_GLFILTER_H
extern "C" {
#include <jni.h>
#include "android/asset_manager.h"
#include "android/asset_manager_jni.h"
}
class GLFilter {
public:
void init();
void initFilter(JNIEnv *env, AAssetManager *manager);
};
#endif //TESTNDK_GLFILTER_H