2
我正在嘗試編寫一個使用x264 API的小型C應用程序,並且在編譯帶有x264 libaray鏈接的代碼時遇到問題。從c代碼鏈接到libx264庫Ubuntu
在/ project /目錄中有兩個子文件夾: /project/mycode /和 /project/x264-snapshot-20120120-2245。
我已在後一個子目錄中使用./configure然後'make'安裝了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
所以我嘗試我上面提到的庫鏈接,但沒有找到:
/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
由於可能是明顯的現在,我是相當新的這一點,所以我希望有一個簡單的解決方案