为什么是cygwin?
cygwin是所有windows 的编译平台中,和opencore本来的编译方式最接近的一个,mingw中有很多的头文件和linux下的接口没有实现,而vs2005等微软的平台又和gnu的语法有差异,而且vs2005不支持makefile的这种编译方式。因此采用cygwin是最简便,需要改动最小的方式。
在cygwin下编译通过的步骤:
1,在oscl/oscl/config 下,将linux文件夹copy一份到CYGWIN_NT-5.1
2,将tools_v2/build/make/下的linux.mk copy为 CYGWIN_NT-5.1.mk
3,cygwin下的stuct tm没有变量tm_gmtoff,因此,需要改变oscl/oscl/osclbase/src/oscl_time.inl
其中的OSCL_COND_EXPORT_REF OSCL_INLINE int32 TimeValue::get_local_time()函数改为:
#ifdef __CYGWIN__
inline static int get_gmt_offset()
{
struct timeval now;
time_t t1, t2;
struct tm t;
gettimeofday(&now, NULL);
t1 = now.tv_sec;
t2 = 0;
gmtime_r(&t1, &t);
t.tm_isdst = 0;
t2 = mktime(&t);
return (int)difftime(t1, t2);
}
#endif
OSCL_COND_EXPORT_REF OSCL_INLINE int32 TimeValue::get_local_time()
{
// Daylight saving time offset of 1 hour in the summer
uint dst_offset = 60 * 60;
int32 GMTime = ts.tv_sec;
struct tm *timeptr;
struct tm buffer;
int dstFlag;
timeptr = localtime_r(&ts.tv_sec, &buffer);
#ifdef __CYGWIN__
GMTime -= get_gmt_offset();
#else
GMTime -= timeptr->tm_gmtoff;
#endif
dstFlag = timeptr->tm_isdst;
if (dstFlag == 1)
{
// Daylight saving time. Add an hour's offset to get GMT
GMTime += dst_offset;
}
return GMTime;
}
4,如果文件pvmi/pvmf/build/make/local.mk中的SRCS :没有加上文件pvmf_event_handling.cpp
加上这个源文件(这个bug packetvideo应该解了)。
然后按照在linux下的编译方式进行编译就行了,至于如何编译,请看博客Howto用自己的toolchain编译opencore
在cygwin下编译的时候,系统有可能报告错误“extern_tools_v2/bin/linux/make: cannot execute binary file”
这是因为opencore将路径extern_tools_v2/bin/linux/给加到PATH环境变量下面去了,处理的办法是,要么从PATH环境变量下去掉extern_tools_v2/bin/linux/,或者删掉extern_tools_v2/bin/linux/文件夹下的内容。
本文只是关注如何编译,并没有涉及到如何在windows下完成播放,作者已经完成了采用SDL作为输出方式的采用opencore框架的一个简单的命令行播放器,啥时候有空了,我会发布出来的。