2013-12-21 1 views
2

검색 한 결과 Building FFMPEG with librtmp for android이 내 질문에 응답했지만 필자는 컴파일 과정에서 다른 문제를 발견했습니다.안드로이드에서 librtmp로 FFMPEG를 컴파일 할 때 "정의되지 않은 참조"

첫째, 나는 다음과 같은

--enable-librtmp \ 
    --extra-cflags=-I/home/bradford/Development/FFMPEG/rtmp/rtmpdump/librtmp/ \ 
    --extra-ldflags=-L/home/bradford/Development/FFMPEG/rtmp/rtmpdump/librtmp" 

내가 polarSSL와 librtmp 구축을 포함하도록 플래그를 변경 this github repo의 스크립트를 사용하려고 S74ck3r의 instructions on his github repostream-recorder thread. 즉, 제대로 작동하려면 나타납니다, 나는 librtmp으로는 FFmpeg 컴파일 할 때 나는 librtmp.so, librtmp.a 및 rtmp.h

을 가지고, 나는 오류를

ERROR: librtmp not found 

This SO question helped을 얻을, 나는 수정 이 librtmp에 대한 PKG-설정 보지 것이다 그래야는 FFmpeg의 설정 파일 (PKG-설정은 ... librtmp 알고 있었다하더라도) :

지금 구축
#enabled librtmp && require_pkg_config librtmp librtmp/rtmp.h RTMP_Socket 

, 성공적으로 시작하고, 내가 할 희망 줄 :

librtmp enabled   yes 

그리고 나중에 나는 더보기 좋은 소식 :

... 
Enabled protocols: 
applehttp  http   mmsh 
cache   httpproxy  mmst 
concat   librtmp   mmsu 
crypto   librtmpe  pipe 
fd   librtmps  rtp 
file   librtmpt  tcp 
gopher   librtmpte  udp 
hls   md5 
... 

하지만 결국, 모든 것을하고 설치 단계를 컴파일 한 후, 나는 이러한 유형의 오류 얻을 :

INSTALL libavutil/libavutil.pc 
/tmp/FFMPEG/bin/../lib/gcc/arm-linux-androideabi/4.6/../../../../arm-linux-androideabi/bin/ld: libavformat/librtmp.o: in function rtmp_get_file_handle:libavformat/librtmp.c:190: error: undefined reference to 'RTMP_Socket' 
/tmp/FFMPEG/bin/../lib/gcc/arm-linux-androideabi/4.6/../../../../arm-linux-androideabi/bin/ld: libavformat/librtmp.o: in function rtmp_read_seek:libavformat/librtmp.c:180: error: undefined reference to 'RTMP_SendSeek' 
/tmp/FFMPEG/bin/../lib/gcc/arm-linux-androideabi/4.6/../../../../arm-linux-androideabi/bin/ld: libavformat/librtmp.o: in function rtmp_read_pause:libavformat/librtmp.c:161: error: undefined reference to 'RTMP_Pause' 
/tmp/FFMPEG/bin/../lib/gcc/arm-linux-androideabi/4.6/../../../../arm-linux-androideabi/bin/ld: libavformat/librtmp.o: in function rtmp_close:libavformat/librtmp.c:64: error: undefined reference to 'RTMP_Close' 
/tmp/FFMPEG/bin/../lib/gcc/arm-linux-androideabi/4.6/../../../../arm-linux-androideabi/bin/ld: libavformat/librtmp.o: in function rtmp_write:libavformat/librtmp.c:145: error: undefined reference to 'RTMP_Write' 
/tmp/FFMPEG/bin/../lib/gcc/arm-linux-androideabi/4.6/../../../../arm-linux-androideabi/bin/ld: libavformat/librtmp.o: in function rtmp_read:libavformat/librtmp.c:153: error: undefined reference to 'RTMP_Read' 
/tmp/FFMPEG/bin/../lib/gcc/arm-linux-androideabi/4.6/../../../../arm-linux-androideabi/bin/ld: libavformat/librtmp.o: in function rtmp_open:libavformat/librtmp.c:96: error: undefined reference to 'RTMP_LogSetLevel' 
/tmp/FFMPEG/bin/../lib/gcc/arm-linux-androideabi/4.6/../../../../arm-linux-androideabi/bin/ld: libavformat/librtmp.o: in function rtmp_open:libavformat/librtmp.c:97: error: undefined reference to 'RTMP_LogSetCallback' 
/tmp/FFMPEG/bin/../lib/gcc/arm-linux-androideabi/4.6/../../../../arm-linux-androideabi/bin/ld: libavformat/librtmp.o: in function rtmp_open:libavformat/librtmp.c:118: error: undefined reference to 'RTMP_Init' 
/tmp/FFMPEG/bin/../lib/gcc/arm-linux-androideabi/4.6/../../../../arm-linux-androideabi/bin/ld: libavformat/librtmp.o: in function rtmp_open:libavformat/librtmp.c:119: error: undefined reference to 'RTMP_SetupURL' 
/tmp/FFMPEG/bin/../lib/gcc/arm-linux-androideabi/4.6/../../../../arm-linux-androideabi/bin/ld: libavformat/librtmp.o: in function rtmp_open:libavformat/librtmp.c:127: error: undefined reference to 'RTMP_Connect' 
/tmp/FFMPEG/bin/../lib/gcc/arm-linux-androideabi/4.6/../../../../arm-linux-androideabi/bin/ld: libavformat/librtmp.o: in function rtmp_open:libavformat/librtmp.c:127: error: undefined reference to 'RTMP_ConnectStream' 
/tmp/FFMPEG/bin/../lib/gcc/arm-linux-androideabi/4.6/../../../../arm-linux-androideabi/bin/ld: libavformat/librtmp.o: in function rtmp_open:libavformat/librtmp.c:125: error: undefined reference to 'RTMP_EnableWrite' 
collect2: ld returned 1 exit status 

그리고 내가 할 수있는을 그들을 지나쳐 버리지 마라. 그것은 그 함수에 대한 참조를 포함하고있는 rtmp.h를 찾을 수없는 것처럼 들리지만 그것이 어디에 있어야하는지 (afaik).

또한 내 프로젝트에는 librtmp가 필요합니다. librtmp의 인증 기능이 필요하기 때문에 ffmpeg의 내장 rtmp 기능으로는 충분하지 않습니다.

+1

먼저 librtmp를 빌드하고 .so 또는 .a를 링크해야합니다. Vitamio 4.0 이상을 사용하는 경우 https://github.com/yixia/FFmpeg-Vitamio를 복제하고 ./build_android.sh를 실행하십시오. – crossle

+0

@CrossleSong - 고맙습니다. 지난 3 주 동안 repo가 ​​업데이트 된 것을 볼 수 있습니다. 나는 그것을 다시 돌려 줄거야 – elBradford

답변

0

이 질문을 별도의 질문으로 분해하고 프로세스와 문제를 철저히 철자 해 주셔서 감사합니다.

제공된 데이터를 기반으로 FFmpeg를 빌드하고 프로토콜리스트를보기 위해 바이너리를 실행할 수있었습니다. 그러나 설치 단계가 실패 했습니까? 바이너리 빌드 (.h는 링크 타임이나 런타임이 아닌 컴파일 타임에 필요하기 때문에) rtmp.h 파일이 있어야합니다.

내 생각에 컴파일 된 FFmpeg 바이너리는 librtmp.so에 동적으로 링크되어 있습니다. librtmp.so를이 시스템에 복사 했습니까 (여기서 크로스 컴파일이라고 가정)? 존재하는 경우 라이브러리를 등록하려면 /sbin/ldconfig을 실행 했습니까? ldd ffmpeg을 실행하여 FFmpeg binrary가보고 싶어하는 .so 라이브러리를 확인하십시오. librtmp.so에 대한 링크가 누락 되었습니까?

+0

죄송합니다! 내 질문에 실수를 했으므로 편집했습니다. 나는 그것이 성공적으로 컴파일 된 것처럼 들리게했다. 그렇지 않았습니다. ffmpeg가 librtmp 플래그 세트로 컴파일을 시작하는 데는 약간의 작업이 필요합니다. 작동하지 않을 것으로 보이지만 설치 단계에서 실패합니다. 아마도 누락 된 모든 기능을 참조하는 rtmp.h의 문제점 때문일 것입니다 . – elBradford

0

나는 documented을 성공적으로 안드로이드에 대한 librtmp와 FFmpeg 2.1.3을 구축하는 내 과정을했습니다.

간단히, 당신이 열기/PolarSSL 및 librtmp를 빌드하면,는 FFmpeg의 configure을 다음과 같이 변경 the latest FFmpeg release를 다운로드합니다

# ffmpegX.X.X/configure 
... 
# Replace the following lines: 

#SLIBNAME_WITH_MAJOR='$(SLIBNAME).$(LIBMAJOR)' 
#LIB_INSTALL_EXTRA_CMD='$$(RANLIB) "$(LIBDIR)/$(LIBNAME)"' 
#SLIB_INSTALL_NAME='$(SLIBNAME_WITH_VERSION)' 
#SLIB_INSTALL_LINKS='$(SLIBNAME_WITH_MAJOR) $(SLIBNAME)' 

# With: 

SLIBNAME_WITH_MAJOR='$(SLIBPREF)$(FULLNAME)-$(LIBMAJOR)$(SLIBSUF)' 
LIB_INSTALL_EXTRA_CMD='$$(RANLIB) "$(LIBDIR)/$(LIBNAME)"' 
SLIB_INSTALL_NAME='$(SLIBNAME_WITH_MAJOR)' 
SLIB_INSTALL_LINKS='$(SLIBNAME)' 

... 

# Replace this: 
#enabled librtmp && require_pkg_config librtmp librtmp/rtmp.h RTMP_Socket 
# With: 
enabled librtmp && require librtmp librtmp/rtmp.h RTMP_Socket -L/path/to/rtmpdump/librtmp/android/arm/lib -lrtmp 

그리고는 FFmpeg 컴파일하려면 다음 빌드 스크립트를 사용

# ffmpegX.X.X/build_ffmpeg_with_librtmp_for_android.sh 
#!/bin/bash 
NDK=/path/to/android-ndk-r9c 
SYSROOT=$NDK/platforms/android-19/arch-arm/ 
TOOLCHAIN=$NDK/toolchains/arm-linux-androideabi-4.8/prebuilt/darwin-x86_64 

OPENSSL_DIR=/path/to/openssl-android/ 
LIBRTMP_DIR=/path/to/rtmpdump/librtmp/ 
# Note: Change above variables to match your system 
function build_one 
{ 
./configure \ 
    --prefix=$PREFIX \ 
    --enable-librtmp \ 
    --enable-shared \ 
    --disable-static \ 
    --disable-doc \ 
    --disable-programs \ 
    --disable-doc \ 
    --disable-symver \ 
    --cross-prefix=$TOOLCHAIN/bin/arm-linux-androideabi- \ 
    --target-os=linux \ 
    --arch=arm \ 
    --enable-cross-compile \ 
    --sysroot=$SYSROOT \ 
    --extra-cflags="-Os -fpic $ADDI_CFLAGS" \ 
    --extra-ldflags="$ADDI_LDFLAGS" \ 
    $ADDITIONAL_CONFIGURE_FLAG 
make clean 
make -j8 
make install 
} 
CPU=arm 
PREFIX=$(pwd)/android/$CPU 
ADDI_CFLAGS="-marm -I${OPENSSL_DIR}include -I${LIBRTMP_DIR}android/arm/include -L${LIBRTMP_DIR}android/arm/lib -lrtmp" 
ADDI_LFLAGS="-L${OPENSSL_DIR}libs/armeabi -L${LIBRTMP_DIR}android/arm/lib -lrtmp" 
build_one 

이 일을 도와 주신 내 친구 Chris에게 감사드립니다.

관련 문제