x264 API를 사용하는 작은 C 응용 프로그램을 작성하려고하는데 x264 libaray에 대한 링크로 코드를 컴파일하는 데 문제가 있습니다.C 코드 우분투에서 libx264 라이브러리에 연결
/project/디렉토리에는 /project/mycode /와 /project/x264-snapshot-20120120-2245라는 두 개의 하위 폴더가 있습니다.
./configure를 사용하여 후자의 하위 디렉토리에 x264를 설치 한 다음 '확인'을했습니다. 이와 같이 라이브러리에 연결하고 싶습니다. /project/x264-snapshot-20120120-2245/libx264.a
/project/mycode/단일 소스 코드 파일 (prototype.c)이 있습니다. 다음의 수입이 있습니다
예상대로#include <stdio.h>
#include <inttypes.h>
#include "../x264-snapshot-20120120-2245/x264_config.h"
#include "../x264-snapshot-20120120-2245/x264.h"
나는 x264 라이브러리에 연결하지 않고 컴파일하려고하면, 나는 오류 얻을 :
/project/mycode: gcc -o prototype prototype.c
/tmp/cc5NwRTp.o: In function `main':
prototype.c:(.text+0x6c): undefined reference to `x264_param_default_preset'
prototype.c:(.text+0xf6): undefined reference to `x264_param_apply_profile'
collect2: ld returned 1 exit status
그래서 내가 위에서 언급 한 라이브러리를 연결하려고를, 하지만 찾을 수 없습니다 :
(210)/project/mycode: gcc -o prototype prototype.c -I../x264-snapshot-20120120-2245/ -llibx264.a
/usr/bin/ld: cannot find -llibx264.a
collect2: ld returned 1 exit status
내가 좋아하는 몇 가지 변화, 시도했다 : 지금 아마 알 수있는 바와 같이
gcc -o prototype prototype.c -I../x264-snapshot-20120120-2245/ -l ../x264-snapshot-20120120-2245/libx264.a
gcc -o prototype prototype.c -I../x264-snapshot-20120120-2245/ -llibx264
gcc -I ../x264-snapshot-20120120-2245/ -llibx264.a -o prototype prototype.c
을, 나는 이것에 비교적 새로운 해요, 그래서 쉬운 솔루션