原创作品,允许转载,转载时请务必以超链接形式标明文章
原始出处 、作者信息和本声明。否则将追究法律责任。
http://jeremiah.blog.51cto.com/539865/114550
如果按照上一篇博客《windows平台下vlc编译之一:编译环境构建》安装好了Cygwin,下载了源码和第三方库之后,我们就可以编译vlc了。这篇博客先讲如何编译vlc-0.8.6i.
步骤一:解压源码和第三方库。
将vlc-0.8.6i.tar.gz和contrib-20070530-win32-bin-gcc-3.4.5-only.tar.bz2拷贝到/home/username/下面(username为登陆的用户目录),运行以下命令解压:
tar xjvf contrib-20070530-win32-bin-gcc-3.4.5-only.tar.bz2 -C /
tar xzvf vlc-0.8.6i.tar.gz
tar xzvf vlc-0.8.6i.tar.gz
做一点点清理工作
rm -rf /usr/win32/bin/moc
rm -rf /usr/win32/bin/rcc
rm -rf /usr/win32/bin/uic
rm -rf /usr/win32/bin/rcc
rm -rf /usr/win32/bin/uic
步骤二:Bootstrap
cd vlc-0.8.6i
./bootstrap
./bootstrap
可能出现的错误:
+ aclocal-1.9 -I m4
/usr/bin/m4:configure.ac:4643: cannot create temporary file for diversion: Permission denied
/usr/bin/m4:configure.ac:4643: cannot create temporary file for diversion: Permission denied
autom4te-2.61: /usr/bin/m4 failed with exit status: 1
aclocal-1.9: autom4te failed with exit status: 1
aclocal-1.9: autom4te failed with exit status: 1
分析:杀毒软件有关系,比如Jeremiah用的Mcafee就会出这样的错误。
解决方法:关闭杀毒软件重新运行./bootstrap。
步骤三:编辑vlc脚本
在vic-0.8.6i下新建文本文件"configure-vlc01.sh"(见附件),内容如下:
PKG_CONFIG_PATH=/usr/win32/lib/pkgconfig \
CPPFLAGS="-I/usr/win32/include -I/usr/win32/include/ebml" \
LDFLAGS=-L/usr/win32/lib \
CC="gcc -mno-cygwin" CXX="g++ -mno-cygwin" \
./configure \
--disable-gtk \
--enable-nls --enable-sdl --with-sdl-config-path=/usr/win32/bin \
--enable-ffmpeg --with-ffmpeg-mp3lame --with-ffmpeg-faac \
--with-ffmpeg-zlib --enable-faad --enable-flac --enable-theora \
--with-wx-config-path=/usr/win32/bin \
--with-freetype-config-path=/usr/win32/bin \
--with-fribidi-config-path=/usr/win32/bin \
--enable-live555 --with-live555-tree=/usr/win32/live.com \
--enable-caca --with-caca-config-path=/usr/win32/bin \
--with-xml2-config-path=/usr/win32/bin \
--with-dvdnav-config-path=/usr/win32/bin \
--disable-cddax --disable-vcdx --enable-goom \
--enable-twolame --enable-dvdread \
--enable-shared-libvlc \
--enable-debug
CPPFLAGS="-I/usr/win32/include -I/usr/win32/include/ebml" \
LDFLAGS=-L/usr/win32/lib \
CC="gcc -mno-cygwin" CXX="g++ -mno-cygwin" \
./configure \
--disable-gtk \
--enable-nls --enable-sdl --with-sdl-config-path=/usr/win32/bin \
--enable-ffmpeg --with-ffmpeg-mp3lame --with-ffmpeg-faac \
--with-ffmpeg-zlib --enable-faad --enable-flac --enable-theora \
--with-wx-config-path=/usr/win32/bin \
--with-freetype-config-path=/usr/win32/bin \
--with-fribidi-config-path=/usr/win32/bin \
--enable-live555 --with-live555-tree=/usr/win32/live.com \
--enable-caca --with-caca-config-path=/usr/win32/bin \
--with-xml2-config-path=/usr/win32/bin \
--with-dvdnav-config-path=/usr/win32/bin \
--disable-cddax --disable-vcdx --enable-goom \
--enable-twolame --enable-dvdread \
--enable-shared-libvlc \
--enable-debug
想知道每个--enable,--disable是什么意思,可以使用如下命令将configure的参数信息保存到confHelp.txt中,以后对照该文件查看修改vlc编译脚本。
./configure -h > confHelp.txt
步骤四:运行vlc脚本
转换下脚本的编码格式:
dos2unix configure-vlc01.sh
运行脚本:
./configure-vlc01.sh
如果脚本遇到了类似Permission denied的错误,提升脚本的权限:
chmod 777 configure-vlc01.sh
如果脚本运行成功,则会显示如下信息:
vlc configuration
--------------------
vlc version : 0.8.6i
system : mingw32
architecture : i686 mmx
build flavour : debug optim devel
vlc aliases : svlc wxvlc
You can tune the compiler flags in vlc-config.
To build vlc and its plugins, type `./compile' or `make'.
--------------------
vlc version : 0.8.6i
system : mingw32
architecture : i686 mmx
build flavour : debug optim devel
vlc aliases : svlc wxvlc
You can tune the compiler flags in vlc-config.
To build vlc and its plugins, type `./compile' or `make'.
步骤五:作一点点修改工作
由于在编译完成后vlc.exe会要求libvlc.dll.exe,这显然是不对的。应该直接去调用libtool.dll,解决方案为:
修改"/tmp/vlc-0.8.6i"目录下的libtool文件4760行
prog)
case $host in
*cygwin*) output=`$echo $output | ${SED} -e 's,.exe$,,;s,$,.exe,'` ;;
esac
为:
prog)
case $host in
#*cygwin*) output=`$echo $output | ${SED} -e 's,.exe$,,;s,$,.exe,'` ;;
*cygwin*) output=`$echo $output` ;;
esac
步骤六:make
运行:
make
如果是双核的电脑,可以运行:
make -j2
如果的电脑有N多个cpu,则参数可以为-jN,N为cpu个数。这样能将几个cpu都利用起来,执行时间会缩短一些。
make的执行期间可能会出现错误,需要修改一些文件,当修改完成后,再执行make,以前make的东西会保留而继续make刚才出错的地方。其实这种方式很方便我们以后修改源代码,重新make的时候它只会编译修改的地方,很节省时间。
错误1:
In file included from file.c:30:
/usr/lib/gcc/i686-pc-mingw32/3.4.4/../../../../i686-pc-mingw32/include/sys/stat.
h:113: error: parse error before "off_t"
/usr/lib/gcc/i686-pc-mingw32/3.4.4/../../../../i686-pc-mingw32/include/sys/stat.
h:118: error: parse error before '}' token
make[4]: *** [libaccess_output_file_plugin_a-file.o] Error 1
make[4]: Leaving directory `/home/wangwei1/vlc-0.8.6i/modules/access_output'
make[3]: *** [all-modules] Error 1
make[3]: Leaving directory `/home/wangwei1/vlc-0.8.6i/modules/access_output'
make[2]: *** [all-recursive] Error 1
make[2]: Leaving directory `/home/wangwei1/vlc-0.8.6i/modules'
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory `/home/wangwei1/vlc-0.8.6i'
make: *** [all] Error 2
/usr/lib/gcc/i686-pc-mingw32/3.4.4/../../../../i686-pc-mingw32/include/sys/stat.
h:113: error: parse error before "off_t"
/usr/lib/gcc/i686-pc-mingw32/3.4.4/../../../../i686-pc-mingw32/include/sys/stat.
h:118: error: parse error before '}' token
make[4]: *** [libaccess_output_file_plugin_a-file.o] Error 1
make[4]: Leaving directory `/home/wangwei1/vlc-0.8.6i/modules/access_output'
make[3]: *** [all-modules] Error 1
make[3]: Leaving directory `/home/wangwei1/vlc-0.8.6i/modules/access_output'
make[2]: *** [all-recursive] Error 1
make[2]: Leaving directory `/home/wangwei1/vlc-0.8.6i/modules'
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory `/home/wangwei1/vlc-0.8.6i'
make: *** [all] Error 2
解决方案:
//在"/usr/i686-pc-mingw32/include/sys"目录下的stat.h的文件开始处添加如下代码
#ifndef _OFF_T DEFINED
typedef long off_t;
#define _OFF_T DEFINED
#endif
#ifndef _OFF_T DEFINED
typedef long off_t;
#define _OFF_T DEFINED
#endif
错误2:
libdtstofloat32_plugin.a(libdtstofloat32_plugin_a-dtstofloat32.o): In function `
Open':
/home/wangwei1/vlc-0.8.6i/modules/audio_filter/converter/dtstofloat32.c:219: und
efined reference to `_dca_init'
libdtstofloat32_plugin.a(libdtstofloat32_plugin_a-dtstofloat32.o): In function `
DoWork':
/home/wangwei1/vlc-0.8.6i/modules/audio_filter/converter/dtstofloat32.c:303: und
efined reference to `_dca_syncinfo'
/home/wangwei1/vlc-0.8.6i/modules/audio_filter/converter/dtstofloat32.c:312: und
efined reference to `_dca_frame'
/home/wangwei1/vlc-0.8.6i/modules/audio_filter/converter/dtstofloat32.c:331: und
efined reference to `_dca_blocks_num'
/home/wangwei1/vlc-0.8.6i/modules/audio_filter/converter/dtstofloat32.c:335: und
efined reference to `_dca_block'
/home/wangwei1/vlc-0.8.6i/modules/audio_filter/converter/dtstofloat32.c:341: und
efined reference to `_dca_samples'
/home/wangwei1/vlc-0.8.6i/modules/audio_filter/converter/dtstofloat32.c:331: und
efined reference to `_dca_blocks_num'
libdtstofloat32_plugin.a(libdtstofloat32_plugin_a-dtstofloat32.o): In function `
Destroy':
/home/wangwei1/vlc-0.8.6i/modules/audio_filter/converter/dtstofloat32.c:376: und
efined reference to `_dca_free'
libdtstofloat32_plugin.a(libdtstofloat32_plugin_a-dtstofloat32.o): In function `
CloseFilter':
/home/wangwei1/vlc-0.8.6i/modules/audio_filter/converter/dtstofloat32.c:430: und
efined reference to `_dca_free'
collect2: ld returned 1 exit status
make[6]: *** [libdtstofloat32_plugin.dll] Error 1
make[6]: Leaving directory `/home/wangwei1/vlc-0.8.6i/modules/audio_filter/conve
rter'
make[5]: *** [all-modules] Error 1
make[5]: Leaving directory `/home/wangwei1/vlc-0.8.6i/modules/audio_filter/conve
rter'
make[4]: *** [all-recursive] Error 1
make[4]: Leaving directory `/home/wangwei1/vlc-0.8.6i/modules/audio_filter'
make[3]: *** [all] Error 2
make[3]: Leaving directory `/home/wangwei1/vlc-0.8.6i/modules/audio_filter'
make[2]: *** [all-recursive] Error 1
make[2]: Leaving directory `/home/wangwei1/vlc-0.8.6i/modules'
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory `/home/wangwei1/vlc-0.8.6i'
make: *** [all] Error 2
Open':
/home/wangwei1/vlc-0.8.6i/modules/audio_filter/converter/dtstofloat32.c:219: und
efined reference to `_dca_init'
libdtstofloat32_plugin.a(libdtstofloat32_plugin_a-dtstofloat32.o): In function `
DoWork':
/home/wangwei1/vlc-0.8.6i/modules/audio_filter/converter/dtstofloat32.c:303: und
efined reference to `_dca_syncinfo'
/home/wangwei1/vlc-0.8.6i/modules/audio_filter/converter/dtstofloat32.c:312: und
efined reference to `_dca_frame'
/home/wangwei1/vlc-0.8.6i/modules/audio_filter/converter/dtstofloat32.c:331: und
efined reference to `_dca_blocks_num'
/home/wangwei1/vlc-0.8.6i/modules/audio_filter/converter/dtstofloat32.c:335: und
efined reference to `_dca_block'
/home/wangwei1/vlc-0.8.6i/modules/audio_filter/converter/dtstofloat32.c:341: und
efined reference to `_dca_samples'
/home/wangwei1/vlc-0.8.6i/modules/audio_filter/converter/dtstofloat32.c:331: und
efined reference to `_dca_blocks_num'
libdtstofloat32_plugin.a(libdtstofloat32_plugin_a-dtstofloat32.o): In function `
Destroy':
/home/wangwei1/vlc-0.8.6i/modules/audio_filter/converter/dtstofloat32.c:376: und
efined reference to `_dca_free'
libdtstofloat32_plugin.a(libdtstofloat32_plugin_a-dtstofloat32.o): In function `
CloseFilter':
/home/wangwei1/vlc-0.8.6i/modules/audio_filter/converter/dtstofloat32.c:430: und
efined reference to `_dca_free'
collect2: ld returned 1 exit status
make[6]: *** [libdtstofloat32_plugin.dll] Error 1
make[6]: Leaving directory `/home/wangwei1/vlc-0.8.6i/modules/audio_filter/conve
rter'
make[5]: *** [all-modules] Error 1
make[5]: Leaving directory `/home/wangwei1/vlc-0.8.6i/modules/audio_filter/conve
rter'
make[4]: *** [all-recursive] Error 1
make[4]: Leaving directory `/home/wangwei1/vlc-0.8.6i/modules/audio_filter'
make[3]: *** [all] Error 2
make[3]: Leaving directory `/home/wangwei1/vlc-0.8.6i/modules/audio_filter'
make[2]: *** [all-recursive] Error 1
make[2]: Leaving directory `/home/wangwei1/vlc-0.8.6i/modules'
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory `/home/wangwei1/vlc-0.8.6i'
make: *** [all] Error 2
解决方案:
修改"/tmp/vlc-0.8.6i"目录下的vlc-config 文件
dtstofloat32)
ldflags="${ldflags} -ldts_pic"
为:
dtstofloat32)
ldflags="${ldflags} -ldts"
dtstofloat32)
ldflags="${ldflags} -ldts_pic"
为:
dtstofloat32)
ldflags="${ldflags} -ldts"
错误3:
/usr/win32/lib/libFLAC.a(bitwriter.o):bitwriter.c:(.text+0x3fb): undefined refer
ence to `_ntohl@4'
/usr/win32/lib/libFLAC.a(bitwriter.o):bitwriter.c:(.text+0x488): undefined refer
ence to `_ntohl@4'
/usr/win32/lib/libFLAC.a(bitwriter.o):bitwriter.c:(.text+0x4e5): undefined refer
ence to `_ntohl@4'
/usr/win32/lib/libFLAC.a(bitwriter.o):bitwriter.c:(.text+0x57f): undefined refer
ence to `_ntohl@4'
/usr/win32/lib/libFLAC.a(bitwriter.o):bitwriter.c:(.text+0x5d5): undefined refer
ence to `_ntohl@4'
/usr/win32/lib/libFLAC.a(bitwriter.o):bitwriter.c:(.text+0x66f): more undefined
references to `_ntohl@4' follow
collect2: ld returned 1 exit status
make[4]: *** [libflacdec_plugin.dll] Error 1
make[4]: Leaving directory `/home/wangwei1/vlc-0.8.6i/modules/codec'
make[3]: *** [all-modules] Error 1
make[3]: Leaving directory `/home/wangwei1/vlc-0.8.6i/modules/codec'
make[2]: *** [all-recursive] Error 1
make[2]: Leaving directory `/home/wangwei1/vlc-0.8.6i/modules'
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory `/home/wangwei1/vlc-0.8.6i'
make: *** [all] Error 2
ence to `_ntohl@4'
/usr/win32/lib/libFLAC.a(bitwriter.o):bitwriter.c:(.text+0x488): undefined refer
ence to `_ntohl@4'
/usr/win32/lib/libFLAC.a(bitwriter.o):bitwriter.c:(.text+0x4e5): undefined refer
ence to `_ntohl@4'
/usr/win32/lib/libFLAC.a(bitwriter.o):bitwriter.c:(.text+0x57f): undefined refer
ence to `_ntohl@4'
/usr/win32/lib/libFLAC.a(bitwriter.o):bitwriter.c:(.text+0x5d5): undefined refer
ence to `_ntohl@4'
/usr/win32/lib/libFLAC.a(bitwriter.o):bitwriter.c:(.text+0x66f): more undefined
references to `_ntohl@4' follow
collect2: ld returned 1 exit status
make[4]: *** [libflacdec_plugin.dll] Error 1
make[4]: Leaving directory `/home/wangwei1/vlc-0.8.6i/modules/codec'
make[3]: *** [all-modules] Error 1
make[3]: Leaving directory `/home/wangwei1/vlc-0.8.6i/modules/codec'
make[2]: *** [all-recursive] Error 1
make[2]: Leaving directory `/home/wangwei1/vlc-0.8.6i/modules'
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory `/home/wangwei1/vlc-0.8.6i'
make: *** [all] Error 2
解决方案:
修改"/tmp/vlc-0.8.6i"目录下的vlc-config 文件
flacdec)
ldflags="${ldflags} -lFLAC"
为:
flacdec)
ldflags="${ldflags} -lFLAC -lws2_32"
flacdec)
ldflags="${ldflags} -lFLAC"
为:
flacdec)
ldflags="${ldflags} -lFLAC -lws2_32"
错误4:
/usr/lib/gcc/i686-pc-mingw32/3.4.4/../../../../i686-pc-mingw32/include/wchar.h:4
27: error: `off_t' does not name a type
make[3]: *** [libaxvlc_a-main.o] Error 1
make[3]: Leaving directory `/home/wangwei1/vlc-0.8.6i/activex'
make[2]: *** [all] Error 2
make[2]: Leaving directory `/home/wangwei1/vlc-0.8.6i/activex'
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory `/home/wangwei1/vlc-0.8.6i'
make: *** [all] Error 2
27: error: `off_t' does not name a type
make[3]: *** [libaxvlc_a-main.o] Error 1
make[3]: Leaving directory `/home/wangwei1/vlc-0.8.6i/activex'
make[2]: *** [all] Error 2
make[2]: Leaving directory `/home/wangwei1/vlc-0.8.6i/activex'
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory `/home/wangwei1/vlc-0.8.6i'
make: *** [all] Error 2
解决方案:
//在"/usr/i686-pc-mingw32/include/"目录下的wchar.h的文件开始处添加如下代码
#ifndef _OFF_T DEFINED
typedef long off_t;
#define _OFF_T DEFINED
#endif
#ifndef _OFF_T DEFINED
typedef long off_t;
#define _OFF_T DEFINED
#endif
一般会遇到这四个错误,如果还出现了其他错误,肯定是哪一步搞错了,如果还是有错误,RPWT。
步骤七:打包
执行以下命令就会得到绿色版的vlc:
make package-win32-base
在vlc-0.8.6i的目录下又会出现一个目录vlc-0.8.6i,里面就是编译好的vlc了。
如果执行:
make package-win32-zip
得到的zip文件就是官网上提供的/win32/*.zip文件了。
如果想得到安装文件(后面讲ActiveX的时候会用到),首先需要下载NSIS 2.41,给个连接:
[url]http://prdownloads.sourceforge.net/nsis/nsis-2.41-setup.exe?download[/url]。
安装NSIS 2.41,然后在打包好的vlc-0.8.6i下面右键vlc.win32.nsi,选择Compile NSIS .。
期间会出错误,有关Mozilla插件的:
Error in macro InstallFile . macroline 1
Error in . "E:\cygwin\home\wangwei1\vlc-0.8.6i0\vlc-0.8.6i\vlc.win32.nsi" . line 445 -- aborting creation process
Error in . "E:\cygwin\home\wangwei1\vlc-0.8.6i0\vlc-0.8.6i\vlc.win32.nsi" . line 445 -- aborting creation process
用文本编译器打开vlc.win32.nsi,在第445行前加上;(分号)注释起来。
; !insertmacro InstallFile mozilla\npvlc.dll
重新Compile NSIS .。运行成功之后,在编译好的vlc-0.8.6i同级目录里面就会出现vlc-${VERSION}-win32.exe这个文件。这个就是自己编译的vlc的安装文件了。(文件名应该是vlc-0.8.6i-win32.exe,但是可能NSIS的脚本的问题,${VERSION}替换不了,手动改一下就行了。)
2009-07-09更新:
vlc.win32.nsi的第7行加入
!define VERSION "0.8.6i"
可以解决${VERSION}的问题。
至此,vlc-0.8.6i算是编译完成了。
2010-04-09更新:
错误修正:
如果运行vlc出现了“Windows无法访问指定设备...您可能没有合适权限访问”,或者“Permission denied”错误,请在打包好的vlc-0.8.6i目录下执行以下命令。增加两个文件的运行权限。
- chmod 755 vlc.exe vlc.exe.manifest
参考网址:
ps:感谢vlc研究群(49846130)的yjvj提供的资料。