2011-03-01 27 views
3

在获取makefile以查找.c程序的正确库和头文件时出现问题我正在尝试编译。我试图为Apple的HTTP Live Streaming编译一个开源的分段器,它需要libavformat和其他FFMpeg库进行编译。我使用Mac Ports来安装FFMpeg,当我在命令行运行“which ffmpeg”时,它显示的目录是opt/local/bin/ffmpeg,但是在四处搜索之后,这似乎不是该库的目录。位于Snow Leopard上的FFMpeg的libavformat在哪里?

看来,库位于opt/local/include,因为那是我看到头文件的地方。这是我的makefile与疑似目录:

所有: 的gcc -Wall -g live_segmenter.c -o live_segmenter -I /选择/本地/包括-I /选择/ local/bin目录-I /选择/ local/include/libavutil -L/opt/local/include/libavformat -libavformat -L/opt/local/include -libavcodec -L/opt/local/include -libavutil -L/opt/local/include -libavcore -lbz2 - LM -lz -lfaac -lmp3lame -lx264 -lfaad -lpthread

clean: 
rm -f live_segmenter 

这里是输出试图编译后:

gcc -Wall -g live_segmenter.c -o live_segmenter -I/opt/local/include -I/opt/local/bin - I/opt/local/include/libavutil -L/opt/local/include/libavformat -libavformat -L/opt/local/include -libavcodec -L/opt/local/include -libavutil -L/opt/local/include -libavcore -lbz2 -lm -lz -lfaac -lmp3lame -lx264 -lfaad -lpthread

ld: library not found for -libavformat 
collect2: ld returned 1 exit status 
make: *** [all] Error 1 

我也试图运行“的ffmpeg -version”,看看ffmpeg的正确建立,它似乎是这样我已经用完了就做什么的想法。任何帮助或指向正确的方向都会很棒。谢谢!

回答

3

我认为你有太多 - 我和不够-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包括从lib<libname>无论在-L目录列表。

试试这个,而是:

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

+0

哇以后7个月潜在的回答我的问题!太兴奋了。我独自离开了这个问题,并在其他事情上工作,但我一定会尽快尝试这个问题,并让你知道它是否工作!谢谢您的帮助。 – winnicki 2011-09-29 23:36:01

+0

ld:库找不到-lavcore collect2:ld返回1退出状态 make:*** [all]错误1 – winnicki 2011-10-18 03:57:37

+0

我认为你的回答是对的这只是我似乎缺少/ opt/local中的avcore/lib出于某种原因,所以我认为我需要用avcore配置FFMpeg。 *叹息* – winnicki 2011-10-18 04:22:52