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
由于可能是明显的现在,我是相当新的这一点,所以我希望有一个简单的解决方案