2012년 2월 10일 금요일

mingw64 를 이용한 ffmpeg/x264 x64 빌드 및 VC++ 링크 - building x64 ffmpeg/x264 with mingw64 and link in VC++


< ffmpeg && x264 x64 빌드 >
1. http://www.drangon.org/mingw/ 에서 mingw64 툴체인/소스 다운로드 및 설치
=> 툴체인: mingw-w64-bin-x86_64-20111106 *** 툴체인 mingw-w64-bin-x86_64-20120127 로 하면 mingw64 소스빌드 안됨 !!!
=> mingw64 소스: mingw-w64-v2.0.1 (소스 빌드하고 싶을때만)
2. msys 설치
3. ffmpeg 빌드
./configure --enable-memalign-hack
*** pr.exe, yasm.exe, pkg-config.exe(libglib-2.0_0.dll, intl.dll, libiconv-2.dll) 등 필요한것들 msys/bin 밑으로 복사
make

4. x264 빌드
./configure --cross-prefix=x86_64-w64-mingw32- --host=x86_64-pc-mingw32
endian test failed => configure 파일에서 endian test 하는 부분 전부 주석처리

x86_64-w64-mingw32-ar: command not found
x86_64-w64-mingw32-ranlib: command not found
=> mingw64/bin 아래에 ar.exe,ranlib.exe 복사본만들어서 파일 이름 위와같이 변경

dumpbin /headers libavcodec.lib | more => x64 빌드되었는지 확인
for /R %f in (*.obj *.lib) do @echo %f && dumpbin /headers %f | findstr /c:"machine (x86)"

5. mingw64 툴체인 디렉토리에서 libmingwex.a, libgcc.a 복사 링크
6. unresolved external symbol __mingw_raise_matherr 등 => libdummy.a 링크로 해결
7.
libavformat.a(tcp.o) : error LNK2001: unresolved external symbol gai_strerrorA
libavformat.a(udp.o) : error LNK2001: unresolved external symbol gai_strerrorA
=> config.h 에
#define HAVE_GETADDRINFO 1 -> 0 수정

8. VC++ 디버그 모드 빌드시 에러처리
libmingwex.a(lib64_libmingwex_a-wassert.o) : error LNK2005: _wassert already defined in MSVCRTD.lib(MSVCR90D.dll)
=> ar -d libmingwex.a lib64_libmingwex_a-wassert.o

소스수정으로 해결하는 방법
=> 툴채인 mingw-w64-bin-x86_64-20111106 버전으로 할것 !!!
=> mingw-w64-crt\misc\wassert.c 에서 __wassert() => ___wassert() 변경

*** .a 파일의 object member 보기
dumpbin /list libmingwex.a

*** dummy.c (libdummy.a) 소스 (6번 unresolved external symbol 에러해결)


int mingw_app_type = 0;
void __mingw_raise_matherr (int typ, const char *name, double a1, double a2,
   double rslt)
{
}

typedef int HMODULE;
HMODULE __mingw_get_msvcrt_handle(void)
{
return 0;
}

댓글 없음:

댓글 쓰기