Skip to content Skip to sidebar Skip to footer

Undefined Reference Error, Can Not Create Shared Library

Tried so many ways to solve problem but no luck. Here is my Android.mk: LOCAL_PATH := $(call my-dir) include $(CLEAR_VARS) LOCAL_MODULE := avcodec LOCAL_SRC_FILES :=libavcodec.a

Solution 1:

Make sure you have added the extern "C" block around the include of the libavcodec and swscale headers, e.g. like this:

extern"C" {
#include<libavcodec/avcodec.h>#include<libswscale/swscale.h>
}

See https://libav.org/faq.html#I_0027m-using-Libav-from-within-my-C_002b_002b-application-but-the-linker-complains-about-missing-symbols-which-seem-to-be-available_002e for documentation that explains this.


EDIT: Also, are you sure that the prebuilt libavcodec.a is for the same architecture (armeabi-v7a) as you're building? If you are building your shared library for multiple architectures (armeabi-v7a, x86, etc) you need to have multiple corresponding versions of the prebuilt libraries as well.

Solution 2:

Try ndk-build V=1 to see the actual command that links your library. You want to end up with

-lavformat -lavcodec -lavfilter -lavutil -lswscale

in that order (as here), but I am not sure where avresample swresample x264 should fit. Rearrange your LOCAL_STATIC_LIBRARIES accordingly.

Post a Comment for "Undefined Reference Error, Can Not Create Shared Library"