在获取makefile以查找.c程序的正确库和头文件方面有问题,我正在尝试编译。我正在尝试为苹果的HTTP流编译一个开源片段,它需要libavformat和其他FFMpeg库来编译。我使用Mac安装FFMpeg,当我在命令行中运行“哪个ffmpeg”时,它显示的目录是opt/local/bin/ffmpeg,但是在搜索之后,这个目录似乎不是带库的目录。
库似乎位于opt/local/include中,因为这是我看到头文件的地方。下面是带有可疑目录的makefile:
all: gcc -Wall -g live_segmenter.c -o live_segmenter -I/opt/local/bin -I/opt/local/include/libavutil -L/libavutil/-g/libavformat -libavformat -L/opt/ -libavcodec -L/opt/local/ -libavutil -L/opt/live_segmenter -libavcore -lbz2 -lz -lfaac -lmp3lame -lx264 -lfaad -lx264-lfaad
clean:
rm -f live_segmenter下面是试图编译后的输出:
gcc -Wall -g live_segmenter.c -o live_segmenter -I/opt/local/bin - I/opt/local/include /libavutil -L/opt/local/include/libavformat -libavformat -L/opt/ -libavcodec -L/-libavcodec-L/ -libavutil -L/opt/local/include -libavcore -lbz2 -lz -lfaac -lmp3lame -lx264 -lfaad -lfaac-lfaad-lx264-lx264-lfaad-lx264-lfaad -lpthread
ld: library not found for -libavformat
collect2: ld returned 1 exit status
make: *** [all] Error 1我还试着运行"ffmpeg -version“来查看ffmpeg的构建是否正确,而且似乎是这样,所以我对该做什么的想法已经用完了。任何帮助或指向正确的方向将是伟大的。谢谢!
发布于 2011-09-29 21:49:44
我认为你有太多的-I而没有足够的-L。来自gcc(1)关于狮子:
-I dir
Add the directory dir to the list of directories to be searched for
header files. Directories named by -I are searched before the standard
system include directories. If the directory dir is a standard system
include directory, the option is ignored to ensure that the default
search order for system directories and the special treatment of system
headers are not defeated.
-L dir
Add directory dir to the list of directories to be searched for -l.-l<libname>是一个链接器指令,它告诉ld在-L目录列表中的任何位置包含lib<libname>。
试一试,而不是:
gcc -Wall -g live_segmenter.c -o live_segmenter -I/opt/local/include -L/opt/local/lib -lavcodec -lavutil -lavcore -lbz2 -lm -lz -lfaac -lmp3lame -lx264 -lfaad -lpthread
https://stackoverflow.com/questions/5150365
复制相似问题