FFMPEG Library Build

Dev/Library 2011. 12. 16. 14:01
FFMPEG 빌드에 대해서 여러 글들이 있지만 예전 자료들이라 현재 버전을 빌드하는데는 참고가 되긴 하지만 맞지 않습니다. 그래서 플랫폼 별로 빌드 하는 방법을 정리합니다.

1.) Windows용 Library
2.) Mac, IPhone용 Library
 



1.) Windows용 Library

1. Download MinGW
  - http://sourceforge.net/projects/mingw/files/
  - mingw-get-inst-XXXXXXXX.exe
  - In install option, check (c++ compile, msys, mingw develop~)

2. Download FFMpeg source code
  - Install git
  - git clone git://git.videolan.org/ffmpeg.git
    (I cloned in C:\MinGW\msys\1.0\home\ydh)

3. Download NASM
  - http://www.nasm.us/pub/nasm/releasebuilds/?C=M;O=D
  - Put nasm.exe to /bin folder under MinGW root directory

4. Add
  - call "C:\Program Files\Microsoft Visual Studio 10.0\VC\bin\VCVARS32.BAT" in second line of C:\MinGW\msys\1.0\msys.bat
   
5. run C:\MinGW\msys\1.0\msys.bat
   cd ffmpeg

6. Configure ffmpeg make file
  - If you did build ago, run this command. 'make distclean'
  - ./configure --enable-gpl --enable-static --disable-shared --enable-memalign-hack --disable-pthreads --enable-w32threads --disable-ffserver --disable-ffplay --disable-debug

7. make & install
  - make
  - make install
      - FFMpeg static libraries will be in C:\MinGW\msys\1.0\local
  - copy lib\ and include\ to your msvc project and include/link these.

8. MSVC's inttypes.h and stdint.h conflict with FFMpeg's variable type. 
   So you must use below inttypes.h and stdint.h in msvc.
   http://code.google.com/p/msinttypes/downloads/list

9. You must link with 'libgcc.a' in C:\MinGW\lib\gcc\mingw32\4.5.2

10. If you compile a msvc project using FFMpeg, you can see this error.
    error LNK2019: unresolved external symbol __imp____lc_codepage referenced in function _mbrlen libmingwex.a
    error LNK2001: unresolved external symbol __imp____lc_codepage libmingwex.a
  
   *. Solution
   1. run CMD
   2. C:\Program Files\Microsoft Visual Studio 10.0\VC\bin\VCVARS32.BAT
   3. cd C:\MinGW\lib
   4. lib -remove:mbrtowc.o libmingwex.a
   5. lib -remove:wcrtomb.o libmingwex.lib
   6. link with 'libgcc.a' to your project.



2.) Mac, IPhone용 Library
*. 맥에서 빌드하는 방법입니다.

1. MacPort 설치
  - $ sudo port -vd selfupdate
  - $ sudo port sync

2. Toolchain 설치
  - $ sudo port install arm-none-eabi-binutils
  - $ sudo port install arm-none-eabi-gcc
  - $ sudo port install arm-none-eabi-gdb

3. FFMpeg Preprocessor 설치
  - preprocessor 다운(https://github.com/yuvi/gas-preprocessor)
  - /usr/local/bin에 복사

4. FFMpeg 소스 받기
  - Install git
  - git clone git://git.videolan.org/ffmpeg.git

5. 자동 설정/빌드 파일 다운로드

  - arm6, arm7, i386, i686, universal library로 설정/빌드를 자동으로 해줍니다.
  - 실행시 어느 용도(arm6, arm7, i386, i686, universal library)로 설정/빌드 할 것인지 선택할 수 있습니다.
  - 빌드 결과물은 "소스디렉토리/build/"에 생성 됩니다.

  - FFMpeg 소스 디렉토리에 복사
  - ./build-ffmepg

: