Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

build报错,找不到native层接口AMediaCodec #4

Open
DongJiyang opened this issue Jan 17, 2019 · 8 comments
Open

build报错,找不到native层接口AMediaCodec #4

DongJiyang opened this issue Jan 17, 2019 · 8 comments

Comments

@DongJiyang
Copy link

如题,编译出错,内容如下:
undefined reference to `AMediaCodec_flush'
开始以为是头文件没包含,但是加了头文件后还是出错。

@DongJiyang
Copy link
Author

已解决。

@oogh
Copy link

oogh commented Jun 14, 2019

@DongJiyang 请问这个是怎么解决的?目前是在master分支上
运行时做了一点点的修改:

minSdkVersion = 21

另外尝试了把 CMakeLists.txt 中强制使用mediandk。但是仍然提示找不到AMediaCodec相关的引用。

错误信息如下:

Build command failed.
Error while executing process /Users/andy/Library/Android/sdk/cmake/3.6.4111459/bin/cmake with arguments {--build /Users/Workspace/xl_player/xl-player-armv7a/.externalNativeBuild/cmake/debug/armeabi-v7a --target xl_render}
[1/2] Building C object CMakeFiles/xl_render.dir/src/main/cpp/xl_decoders/xl_mediacodec.c.o
[2/2] Linking C shared library ../../../../build/intermediates/cmake/debug/obj/armeabi-v7a/libxl_render.so
        FAILED: : && /Users/andy/Library/Android/android-ndk-r14b/toolchains/llvm/prebuilt/darwin-x86_64/bin/clang  --target=armv7-none-linux-androideabi --gcc-toolchain=/Users/andy/Library/Android/android-ndk-r14b/toolchains/arm-linux-androideabi-4.9/prebuilt/darwin-x86_64 --sysroot=/Users/andy/Library/Android/android-ndk-r14b/platforms/android-21/arch-arm -fPIC -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 -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  -O0 -fno-limit-debug-info -O0 -fno-limit-debug-info  -Wl,--build-id -Wl,--warn-shared-textrel -Wl,--fatal-warnings -Wl,--fix-cortex-a8 -Wl,--exclude-libs,libunwind.a -L/Users/andy/Library/Android/android-ndk-r14b/sources/cxx-stl/llvm-libc++/libs/armeabi-v7a -Wl,--no-undefined -Wl,-z,noexecstack -Qunused-arguments -Wl,-z,relro -Wl,-z,now -Wl,--build-id -Wl,--warn-shared-textrel -Wl,--fatal-warnings -Wl,--fix-cortex-a8 -Wl,--exclude-libs,libunwind.a -L/Users/andy/Library/Android/android-ndk-r14b/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,libxl_render.so -o ../../../../build/intermediates/cmake/debug/obj/armeabi-v7a/libxl_render.so CMakeFiles/xl_render.dir/src/main/cpp/xl_audio/xl_audio_player.c.o CMakeFiles/xl_render.dir/src/main/cpp/xl_audio/xl_audio_filter.c.o CMakeFiles/xl_render.dir/src/main/cpp/xl_container/xl_packet_queue.c.o CMakeFiles/xl_render.dir/src/main/cpp/xl_container/xl_packet_pool.c.o CMakeFiles/xl_render.dir/src/main/cpp/xl_container/xl_frame_queue.c.o CMakeFiles/xl_render.dir/src/main/cpp/xl_container/xl_frame_pool.c.o CMakeFiles/xl_render.dir/src/main/cpp/xl_decoders/xl_player_video_sw_decode_thread.c.o CMakeFiles/xl_render.dir/src/main/cpp/xl_decoders/xl_player_video_hw_decode_thread.c.o CMakeFiles/xl_render.dir/src/main/cpp/xl_decoders/xl_player_audio_decode_thread.c.o CMakeFiles/xl_render.dir/src/main/cpp/xl_decoders/xl_mediacodec.c.o CMakeFiles/xl_render.dir/src/main/cpp/xl_video/xl_tracker.c.o CMakeFiles/xl_render.dir/src/main/cpp/xl_video/xl_mat4.c.o CMakeFiles/xl_render.dir/src/main/cpp/xl_video/xl_model.c.o CMakeFiles/xl_render.dir/src/main/cpp/xl_video/xl_mesh_factory.c.o CMakeFiles/xl_render.dir/src/main/cpp/xl_video/xl_model_ball.c.o CMakeFiles/xl_render.dir/src/main/cpp/xl_video/xl_model_rect.c.o CMakeFiles/xl_render.dir/src/main/cpp/xl_video/xl_model_vr.c.o CMakeFiles/xl_render.dir/src/main/cpp/xl_video/xl_texture.c.o CMakeFiles/xl_render.dir/src/main/cpp/xl_video/xl_glsl_program.c.o CMakeFiles/xl_render.dir/src/main/cpp/xl_video/xl_video_render.c.o CMakeFiles/xl_render.dir/src/main/cpp/xl_video/xl_player_gl_thread.c.o CMakeFiles/xl_render.dir/src/main/cpp/xl_utils/xl_statistics.c.o CMakeFiles/xl_render.dir/src/main/cpp/xl_utils/xl_clock.c.o CMakeFiles/xl_render.dir/src/main/cpp/xl_utils/xl_jni_reflect.c.o CMakeFiles/xl_render.dir/src/main/cpp/xl_player.c.o CMakeFiles/xl_render.dir/src/main/cpp/xl_playerCore.c.o CMakeFiles/xl_render.dir/src/main/cpp/xl_player_read_thread.c.o  ../../../../build/intermediates/cmake/debug/obj/armeabi-v7a/libekf.so ../../../../ff_libs/armeabi-v7a/libavcodec-57.so ../../../../ff_libs/armeabi-v7a/libavformat-57.so ../../../../ff_libs/armeabi-v7a/libavutil-55.so ../../../../ff_libs/armeabi-v7a/libavfilter-6.so ../../../../ff_libs/armeabi-v7a/libswresample-2.so -llog -ljnigraphics -landroid -lEGL -lGLESv2 -lOpenSLES -lm && :
/Users/Workspace/xl_player/xl-player-armv7a/src/main/cpp/xl_decoders/xl_mediacodec.c:36: error: undefined reference to 'AMediaCodec_dequeueInputBuffer'
/Users/Workspace/xl_player/xl-player-armv7a/src/main/cpp/xl_decoders/xl_mediacodec.c:40: error: undefined reference to 'AMediaCodec_getInputBuffer'
/Users/Workspace/xl_player/xl-player-armv7a/src/main/cpp/xl_decoders/xl_mediacodec.c:43: error: undefined reference to 'AMediaCodec_queueInputBuffer'
/Users/Workspace/xl_player/xl-player-armv7a/src/main/cpp/xl_decoders/xl_mediacodec.c:60: error: undefined reference to 'AMediaCodec_releaseOutputBuffer'
/Users/Workspace/xl_player/xl-player-armv7a/src/main/cpp/xl_decoders/xl_mediacodec.c:67: error: undefined reference to 'AMediaCodec_dequeueOutputBuffer'
/Users/Workspace/xl_player/xl-player-armv7a/src/main/cpp/xl_decoders/xl_mediacodec.c:80: error: undefined reference to 'AMediaCodec_getOutputFormat'
/Users/Workspace/xl_player/xl-player-armv7a/src/main/cpp/xl_decoders/xl_mediacodec.c:81: error: undefined reference to 'AMediaFormat_getInt32'
/Users/Workspace/xl_player/xl-player-armv7a/src/main/cpp/xl_decoders/xl_mediacodec.c:82: error: undefined reference to 'AMediaFormat_getInt32'
/Users/Workspace/xl_player/xl-player-armv7a/src/main/cpp/xl_decoders/xl_mediacodec.c:83: error: undefined reference to 'AMediaFormat_getInt32'
/Users/Workspace/xl_player/xl-player-armv7a/src/main/cpp/xl_decoders/xl_mediacodec.c:107: error: undefined reference to 'AMEDIAFORMAT_KEY_WIDTH'
/Users/Workspace/xl_player/xl-player-armv7a/src/main/cpp/xl_decoders/xl_mediacodec.c:107: error: undefined reference to 'AMEDIAFORMAT_KEY_HEIGHT'
/Users/Workspace/xl_player/xl-player-armv7a/src/main/cpp/xl_decoders/xl_mediacodec.c:107: error: undefined reference to 'AMEDIAFORMAT_KEY_COLOR_FORMAT'
/Users/Workspace/xl_player/xl-player-armv7a/src/main/cpp/xl_decoders/xl_mediacodec.c:112: error: undefined reference to 'AMediaCodec_flush'
/Users/Workspace/xl_player/xl-player-armv7a/src/main/cpp/xl_decoders/xl_mediacodec.c:122: error: undefined reference to 'AMediaFormat_new'
/Users/Workspace/xl_player/xl-player-armv7a/src/main/cpp/xl_decoders/xl_mediacodec.c:132: error: undefined reference to 'AMediaCodec_createDecoderByType'
/Users/Workspace/xl_player/xl-player-armv7a/src/main/cpp/xl_decoders/xl_mediacodec.c:133: error: undefined reference to 'AMediaFormat_setString'
/Users/Workspace/xl_player/xl-player-armv7a/src/main/cpp/xl_decoders/xl_mediacodec.c:144: error: undefined reference to 'AMediaFormat_setBuffer'
/Users/Workspace/xl_player/xl-player-armv7a/src/main/cpp/xl_decoders/xl_mediacodec.c:145: error: undefined reference to 'AMediaFormat_setBuffer'
/Users/Workspace/xl_player/xl-player-armv7a/src/main/cpp/xl_decoders/xl_mediacodec.c:151: error: undefined reference to 'AMediaCodec_createDecoderByType'
/Users/Workspace/xl_player/xl-player-armv7a/src/main/cpp/xl_decoders/xl_mediacodec.c:152: error: undefined reference to 'AMediaFormat_setString'
/Users/Workspace/xl_player/xl-player-armv7a/src/main/cpp/xl_decoders/xl_mediacodec.c:163: error: undefined reference to 'AMediaFormat_setBuffer'
/Users/Workspace/xl_player/xl-player-armv7a/src/main/cpp/xl_decoders/xl_mediacodec.c:168: error: undefined reference to 'AMediaCodec_createDecoderByType'
/Users/Workspace/xl_player/xl-player-armv7a/src/main/cpp/xl_decoders/xl_mediacodec.c:169: error: undefined reference to 'AMediaFormat_setString'
/Users/Workspace/xl_player/xl-player-armv7a/src/main/cpp/xl_decoders/xl_mediacodec.c:170: error: undefined reference to 'AMediaFormat_setBuffer'
/Users/Workspace/xl_player/xl-player-armv7a/src/main/cpp/xl_decoders/xl_mediacodec.c:174: error: undefined reference to 'AMediaCodec_createDecoderByType'
/Users/Workspace/xl_player/xl-player-armv7a/src/main/cpp/xl_decoders/xl_mediacodec.c:175: error: undefined reference to 'AMediaFormat_setString'
/Users/Workspace/xl_player/xl-player-armv7a/src/main/cpp/xl_decoders/xl_mediacodec.c:191: error: undefined reference to 'AMediaFormat_setInt32'
/Users/Workspace/xl_player/xl-player-armv7a/src/main/cpp/xl_decoders/xl_mediacodec.c:192: error: undefined reference to 'AMediaFormat_setInt32'
/Users/Workspace/xl_player/xl-player-armv7a/src/main/cpp/xl_decoders/xl_mediacodec.c:195: error: undefined reference to 'AMEDIAFORMAT_KEY_MIME'
/Users/Workspace/xl_player/xl-player-armv7a/src/main/cpp/xl_decoders/xl_mediacodec.c:195: error: undefined reference to 'AMEDIAFORMAT_KEY_MIME'
/Users/Workspace/xl_player/xl-player-armv7a/src/main/cpp/xl_decoders/xl_mediacodec.c:195: error: undefined reference to 'AMEDIAFORMAT_KEY_MIME'
/Users/Workspace/xl_player/xl-player-armv7a/src/main/cpp/xl_decoders/xl_mediacodec.c:195: error: undefined reference to 'AMEDIAFORMAT_KEY_MIME'
/Users/Workspace/xl_player/xl-player-armv7a/src/main/cpp/xl_decoders/xl_mediacodec.c:195: error: undefined reference to 'AMEDIAFORMAT_KEY_WIDTH'
/Users/Workspace/xl_player/xl-player-armv7a/src/main/cpp/xl_decoders/xl_mediacodec.c:195: error: undefined reference to 'AMEDIAFORMAT_KEY_HEIGHT'
/Users/Workspace/xl_player/xl-player-armv7a/src/main/cpp/xl_decoders/xl_mediacodec.c:203: error: undefined reference to 'AMediaCodec_configure'
/Users/Workspace/xl_player/xl-player-armv7a/src/main/cpp/xl_decoders/xl_mediacodec.c:207: error: undefined reference to 'AMediaCodec_start'
/Users/Workspace/xl_player/xl-player-armv7a/src/main/cpp/xl_decoders/xl_mediacodec.c:214: error: undefined reference to 'AMediaCodec_stop'
/Users/Workspace/xl_player/xl-player-armv7a/src/main/cpp/xl_decoders/xl_mediacodec.c:219: error: undefined reference to 'AMediaCodec_delete'
/Users/Workspace/xl_player/xl-player-armv7a/src/main/cpp/xl_decoders/xl_mediacodec.c:220: error: undefined reference to 'AMediaFormat_delete'
clang: error: linker command failed with exit code 1 (use -v to see invocation)
ninja: build stopped: subcommand failed.

@oogh
Copy link

oogh commented Jun 14, 2019

目的是想要学习下NdkMediaCodec的使用,但是修改为API21以后,编译就出现了上面的问题

@oogh
Copy link

oogh commented Jun 14, 2019

(><)改错了...(><),已解决

@miricaldad
Copy link

(><)改错了...(><),已解决

你好最近在做这个开发,请问您那边有没有可以让我参考一下的工程呀

@StormGens
Copy link

请问是怎么解决的呀

@yanyi0
Copy link

yanyi0 commented Apr 7, 2022

请问如何解决的,error: undefined reference to 'AMediaFormat_new'

@DreamCloudWalker
Copy link

需要链接mediandk这个库,不然就会找不到。比如CMakeLists.txt里:
target_link_libraries( # Specifies the target library.
your-lib-name

    android
    mediandk
    ${log-lib})

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants