gpt4 book ai didi

c++ - ffmpeg ndk 多重定义 libavcodec.a(golomb.o)

转载 作者:太空宇宙 更新时间:2023-11-04 11:24:10 26 4
gpt4 key购买 nike

我正在尝试将 ffmpeg 作为静态库与 android NDK 链接,但我收到如下“多重定义错误”错误。我还包含了我的构建脚本,该脚本可以很好地运行所有内容,但是当我将 Eclipse 中的库与 ADT 插件一起使用时,我什么也做不了。

由此看来,它似乎想与 VLC 做点什么。我不想与 VLC 有任何关系,只是用于视频流的 ffmpeg。共享库一切正常,但我想要一个非常小的播放器,因为我受限于设备上的空间。

编辑:“log2_tab_tab.o”也有多个定义。

error: jni/libs\libavcodec.a(golomb.o): multiple definition of 'ff_golomb_vlc_len'  Ffplayer            C/C++ Problem
error: jni/libs\libavcodec.a(golomb.o): multiple definition of 'ff_interleaved_dirac_golomb_vlc_code' Ffplayer C/C++ Problem
error: jni/libs\libavcodec.a(golomb.o): multiple definition of 'ff_interleaved_golomb_vlc_len' Ffplayer C/C++ Problem
error: jni/libs\libavcodec.a(golomb.o): multiple definition of 'ff_interleaved_se_golomb_vlc_code' Ffplayer C/C++ Problem
error: jni/libs\libavcodec.a(golomb.o): multiple definition of 'ff_interleaved_ue_golomb_vlc_code' Ffplayer C/C++ Problem
error: jni/libs\libavcodec.a(golomb.o): multiple definition of 'ff_se_golomb_vlc_code' Ffplayer C/C++ Problem
error: jni/libs\libavcodec.a(golomb.o): multiple definition of 'ff_ue_golomb_len' Ffplayer C/C++ Problem
error: jni/libs\libavcodec.a(golomb.o): multiple definition of 'ff_ue_golomb_vlc_code' Ffplayer C/C++ Problem
error: jni/libs\libavcodec.a(log2_tab.o): multiple definition of 'ff_log2_tab' Ffplayer C/C++ Problem
error: jni/libs\libavformat.a(log2_tab.o): multiple definition of 'ff_log2_tab' Ffplayer C/C++ Problem
jni/libs\libavformat.a(golomb_tab.o): previous definition here Ffplayer C/C++ Problem
jni/libs\libavutil.a(log2_tab.o): previous definition here Ffplayer C/C++ Problem
make.exe: *** [obj/local/armeabi-v7a-hard/libffplayer.so] Error 1 Ffplayer C/C++ Problem

使用 ffmpeg (2.4.3) 的最新分支,我的 Android 构建脚本(使用工具链 8,因为它是我正在使用的旧硬件)并想要 NEON 硬件支持:

export ANDROID_NDK=/home/carl/dev/ndk
export TOOLCHAIN=/home/carl/temp/ffmpeg
export SYSROOT=$TOOLCHAIN/sysroot/
$ANDROID_NDK/build/tools/make-standalone-toolchain.sh \
--platform=android-8 --install-dir=$TOOLCHAIN

export PATH=$TOOLCHAIN/bin:$PATH
export CC=arm-linux-androideabi-gcc
export LD=arm-linux-androideabi-ld
export AR=arm-linux-androideabi-ar

CFLAGS="-O3 -Wall -mthumb -pipe -fpic -fasm \
-finline-limit=300 -ffast-math \
-fstrict-aliasing -Werror=strict-aliasing \
-fmodulo-sched -fmodulo-sched-allow-regmoves \
-Werror=implicit-function-declaration \
-Wno-psabi -Wa,--noexecstack"
# -D__ARM_ARCH_5__ -D__ARM_ARCH_5E__ \
# -D__ARM_ARCH_5T__ -D__ARM_ARCH_5TE__ \
# -DANDROID -DNDEBUG"

EXTRA_CFLAGS="-march=armv7-a -mfpu=neon \
-mfloat-abi=softfp -mvectorize-with-neon-quad \
-DHAVE_ISNAN -DHAVE_ISINF
-std=c99"
EXTRA_LDFLAGS="-Wl,--fix-cortex-a8"

FFMPEG_FLAGS="--prefix=/home/dev/ffmpeg/build \
--target-os=linux \
--arch=arm \
--enable-cross-compile \
--cross-prefix=arm-linux-androideabi- \
--enable-shared \
--enable-static \
--enable-small \
--disable-symver \
--disable-doc \
--disable-ffplay \
--disable-ffmpeg \
--disable-ffprobe \
--disable-ffserver \
--disable-avdevice \
--disable-avfilter \
--disable-encoders \
--disable-muxers \
--disable-demuxers \
--disable-filters \
--disable-devices \
--disable-decoders \
--enable-decoder=mjpeg \
--enable-decoder=mp1 \
--enable-decoder=mp2 \
--enable-decoder=mp3 \
--enable-decoder=mpeg1_vdpau \
--enable-decoder=mpeg1video \
--enable-decoder=mpeg2video \
--enable-decoder=mpeg4 \
--enable-decoder=mpeg4_vdpau \
--enable-decoder=mpegvideo \
--enable-decoder=mpeg_xvmc \
--enable-decoder=h261 \
--enable-decoder=h263 \
--enable-decoder=h263i \
--enable-decoder=h263p \
--enable-hwaccel=h263_vaapi \
--enable-hwaccel=h263_vdpau \
--enable-hwaccel=mpeg1_vdpau \
--enable-hwaccel=mpeg1_xvmc \
--enable-hwaccel=mpeg2_dxva2 \
--enable-hwaccel=mpeg2_vaapi \
--enable-hwaccel=mpeg2_vdpau \
--enable-hwaccel=mpeg2_xvmc \
--enable-hwaccel=mpeg4_vaapi \
--enable-hwaccel=mpeg4_vdpau \
--enable-demuxer=aac \
--enable-demuxer=ac3 \
--enable-demuxer=h261 \
--enable-demuxer=h263 \
--enable-demuxer=pcm_s16be \
--enable-demuxer=pcm_s16le \
--enable-demuxer=pcm_s8 \
--enable-demuxer=mpegps \
--enable-demuxer=mpegts \
--enable-demuxer=mpegtsraw \
--enable-demuxer=mpegvideo \
--enable-demuxer=rtp \
--enable-demuxer=rtsp \
--enable-parser=aac \
--enable-parser=mpegvideo \
--enable-parser=ac3 \
--enable-parser=h261 \
--enable-parser=h263 \
--enable-parser=mjpeg \
--enable-parser=mpeg4video \
--enable-parser=mpegaudio \
--enable-protocol=rtp \
--enable-protocol=file \
--enable-protocol=ftp \
--enable-protocol=tcp \
--enable-protocol=http \
--enable-protocol=udp \
--enable-protocol=pipe \
--enable-protocol=unix \
--enable-network \
--disable-swscale \
--enable-asm \
--enable-memalign-hack \
--disable-golomb \
--enable-stripping \
--enable-pthreads \
--disable-symver \
--enable-version3"

./configure $FFMPEG_FLAGS --extra-cflags="$CFLAGS $EXTRA_CFLAGS" \
--extra-ldflags="$EXTRA_LDFLAGS"

make clean
echo "Project now cleaned"
make -j4

echo "Stripping multiple references from libraries"
arm-linux-androideabi-ar d libavcodec.a log2_tab.o
arm-linux-androideabi-ar d libavutil.a log2_tab.o

echo "Done..."

这是运行良好的 Android.mk 文件。

LOCAL_PATH := $(call my-dir)

include $(CLEAR_VARS)
LOCAL_MODULE := avutil
LOCAL_SRC_FILES := libs\libavutil.a
include $(PREBUILT_STATIC_LIBRARY)

include $(CLEAR_VARS)
LOCAL_MODULE := avformat
LOCAL_SRC_FILES := libs\libavformat.a
include $(PREBUILT_STATIC_LIBRARY)

include $(CLEAR_VARS)
LOCAL_MODULE := avcodec
LOCAL_SRC_FILES := libs\libavcodec.a
include $(PREBUILT_STATIC_LIBRARY)

include $(CLEAR_VARS)

LOCAL_MODULE := ffplayer
LOCAL_SRC_FILES := ffplayer.cpp

LOCAL_C_INCLUDES := C:\DEV\ffmpeg\

LOCAL_LDLIBS += -llog -ljnigraphics -lGLESv2 -ldl
LOCAL_LDLIBS += -lstdc++ -lc
LOCAL_LDLIBS += -lz -lm

LOCAL_WHOLE_STATIC_LIBRARIES += libavutil libavformat libavcodec

include $(BUILD_SHARED_LIBRARY)

如果有人能发现其中的问题,我们将不胜感激。

最佳答案

我通过使用其他人使用的类似构建方法弄明白了,只是添加了我自己的选项。这一个还复制文件夹“bin”、“lib”、“include”和“share”。我所需要的只是将“lib”和“include”文件夹添加到我的项目中。呸!

#!/bin/bash

NDK=/home/carl/dev/ndk
PLATFORM=$NDK/platforms/android-9/arch-arm
PREBUILT=$NDK/toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86/
PREFIX=/home/carl/temp/ffmpeg/

function build_one
{
./configure --target-os=linux --prefix=$PREFIX \
--enable-cross-compile \
--enable-runtime-cpudetect \
--enable-asm \
--arch=arm \
--cc=$PREBUILT/bin/arm-linux-androideabi-gcc \
--cross-prefix=$PREBUILT/bin/arm-linux-androideabi- \
--disable-stripping \
--nm=$PREBUILT/bin/arm-linux-androideabi-nm \
--sysroot=$PLATFORM \
--enable-nonfree \
--enable-small \
--disable-symver \
--disable-doc \
--disable-ffplay \
--disable-ffmpeg \
--disable-ffprobe \
--disable-ffserver \
--disable-avdevice \
--disable-avfilter \
--disable-encoders \
--disable-muxers \
--disable-demuxers \
--disable-filters \
--disable-devices \
--disable-decoders \
--enable-decoder=mjpeg \
--enable-decoder=mp1 \
--enable-decoder=mp2 \
--enable-decoder=mp3 \
--enable-decoder=mpeg1_vdpau \
--enable-decoder=mpeg1video \
--enable-decoder=mpeg2video \
--enable-decoder=mpeg4 \
--enable-decoder=mpeg4_vdpau \
--enable-decoder=mpegvideo \
--enable-decoder=mpeg_xvmc \
--enable-decoder=h261 \
--enable-decoder=h263 \
--enable-decoder=h263i \
--enable-decoder=h263p \
--enable-hwaccel=h263_vaapi \
--enable-hwaccel=h263_vdpau \
--enable-hwaccel=mpeg1_vdpau \
--enable-hwaccel=mpeg1_xvmc \
--enable-hwaccel=mpeg2_dxva2 \
--enable-hwaccel=mpeg2_vaapi \
--enable-hwaccel=mpeg2_vdpau \
--enable-hwaccel=mpeg2_xvmc \
--enable-hwaccel=mpeg4_vaapi \
--enable-hwaccel=mpeg4_vdpau \
--enable-demuxer=aac \
--enable-demuxer=ac3 \
--enable-demuxer=h261 \
--enable-demuxer=h263 \
--enable-demuxer=pcm_s16be \
--enable-demuxer=pcm_s16le \
--enable-demuxer=pcm_s8 \
--enable-demuxer=mpegps \
--enable-demuxer=mpegts \
--enable-demuxer=mpegtsraw \
--enable-demuxer=mpegvideo \
--enable-demuxer=rtp \
--enable-demuxer=rtsp \
--enable-parser=aac \
--enable-parser=mpegvideo \
--enable-parser=ac3 \
--enable-parser=h261 \
--enable-parser=h263 \
--enable-parser=mjpeg \
--enable-parser=mpeg4video \
--enable-parser=mpegaudio \
--enable-protocol=rtp \
--enable-protocol=file \
--enable-protocol=ftp \
--enable-protocol=tcp \
--enable-protocol=http \
--enable-protocol=udp \
--enable-protocol=pipe \
--enable-protocol=unix \
--enable-network \
--disable-swscale \
--enable-asm \
--enable-memalign-hack \
--enable-stripping \
--enable-pthreads \
--disable-symver \
--enable-version3 \
--extra-cflags="-I/home/android-ffmpeg/include -fPIC -DANDROID \
-D__thumb__ -mthumb -Wfatal-errors -Wno-deprecated \
-mfloat-abi=softfp -mfpu=vfpv3-d16 -marm -march=armv7-a" \
--extra-ldflags="-L/home/android-ffmpeg/lib"
make -j4 install

$PREBUILT/bin/arm-linux-androideabi-ar d libavcodec/libavcodec.a inverse.o
$PREBUILT/bin/arm-linux-androideabi-ld -rpath-link=$PLATFORM/usr/lib -L$PLATFORM/usr/lib -L$PREFIX/lib -soname libffmpeg.so -shared -nostdlib -z,noexecstack -Bsymbolic --whole-archive --no-undefined -o $PREFIX/libffmpeg.so libavcodec/libavcodec.a libavfilter/libavfilter.a libavresample/libavresample.a libavformat/libavformat.a libavutil/libavutil.a libswscale/libswscale.a -lc -lm -lz -ldl -llog -lx264 --warn-once --dynamic-linker=/system/bin/linker $PREBUILT/lib/gcc/arm-linux-androideabi/4.4.3/libgcc.a
}

build_one

关于c++ - ffmpeg ndk 多重定义 libavcodec.a(golomb.o),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27293065/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com