如何将opencore移植到cygwin

来源:百度文库 编辑:神马文学网 时间:2024/04/24 22:30:02

出自http://blog.csdn.net/hellochenhang/archive/2010/07/21/5751694.aspx

为什么是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()函数改为:

view plaincopy to clipboardprint?
  1. #ifdef __CYGWIN__   
  2. inline static int get_gmt_offset()  
  3. {  
  4.     struct timeval now;  
  5.     time_t t1, t2;  
  6.     struct tm t;  
  7.     gettimeofday(&now, NULL);  
  8.     t1 = now.tv_sec;  
  9.     t2 = 0;  
  10.     gmtime_r(&t1, &t);  
  11.     t.tm_isdst = 0;   
  12.     t2 = mktime(&t);  
  13.     return (int)difftime(t1, t2);  
  14. }  
  15. #endif  
  16. OSCL_COND_EXPORT_REF OSCL_INLINE int32 TimeValue::get_local_time()  
  17. {  
  18.     // Daylight saving time offset of 1 hour in the summer  
  19.     uint dst_offset = 60 * 60;  
  20.     int32 GMTime = ts.tv_sec;  
  21.     struct tm *timeptr;  
  22.     struct tm buffer;  
  23.     int dstFlag;  
  24.     timeptr = localtime_r(&ts.tv_sec, &buffer);  
  25. #ifdef __CYGWIN__  
  26.     GMTime -= get_gmt_offset();  
  27. #else  
  28.     GMTime -= timeptr->tm_gmtoff;  
  29. #endif  
  30.     dstFlag = timeptr->tm_isdst;  
  31.     if (dstFlag == 1)  
  32.     {  
  33.         // Daylight saving time. Add an hour's offset to get GMT  
  34.         GMTime += dst_offset;  
  35.     }  
  36.     return GMTime;  
  37. }  

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框架的一个简单的命令行播放器,啥时候有空了,我会发布出来的。