x264 VS2008下编译成功

vs2008 x264-snapshot-20091006-2245编译成功
2012-01-13 18:01

 x264-snapshot-20091006-2245 是包含vc的最后一个版本了,所以我对这个版本进行了编译,开始一大把错误;然后逐步排查,一一解决;

(1)下载该版本 http://download.videolan.org/pub/videolan/x264/snapshots/

(2)首先编译libx264,错误如下

     2.1)主要是编译时,提示某个“;”分号之类的错误。

       这种错误就是因为变量未声明成功。由于是C代码,VC中,一般要求C代码的变量在函数开头声明。所以,如果变量是在函数中间声明,必然报错。解决方法就是,把这些报错的变量声明放到函数开头或者作用域(大括号)开头。

     解决这个问题后,出现一个错误:analyse.c(2950) : error C2059: syntax error : ‘[' ,错误的地方直接指向static const uint8_t check_mv_lists[X264_MBTYPE_MAX] =
{[P_L0]=1, [B_L0_L0]=1, [B_L1_L1]=2}; 将它改为static const uint8_t check_mv_lists[X264_MBTYPE_MAX] ={0,0,0,0,1,0,0,0,1,0,0,0,2,0,0,0,0,0,0};

编译libx264成功;接着编译x264.exe

2.2)又出现2.1)中的错误,这个好解决,最好的办法就是将变量在函数开始时声明,然后出现一个bug 如下:

muxers.c(299) : error C2146: syntax error :
missing ‘)’ before identifier ‘PRIx32′

fprintf( stderr, “Bad header magic (%”PRIx32″ <=> %s)\n”, *((uint32_t*)header), header );

改为:

fprintf( stderr, “Bad header magic (%ld <=>%s)\n”, *((uint32_t*)header), header );

2.3)解决这个问题后,又出现一个bug:

muxers.c(299) : error C2146: syntax error :missing ‘)’ before identifier ‘PRIx32′

fprintf( stderr, “Bad header magic (%”PRIx32″ <=> %s)\n”, *((uint32_t*)header), header );

改为

fprintf( stderr, “Bad header magic (%ld <=>%s)\n”, *((uint32_t*)header), header );

继续编译:x264 出现如下bug:

1>libx264.lib(encoder.obj) : error LNK2019: unresolved
external symbol _x264_lookahead_is_empty referenced in function
_x264_encoder_encode

1>libx264.lib(encoder.obj) : error LNK2019: unresolved
external symbol _x264_lookahead_get_frames referenced in function
_x264_encoder_encode

1>libx264.lib(encoder.obj) : error LNK2019: unresolved
external symbol _x264_lookahead_put_frame referenced in function
_x264_encoder_encode

1>libx264.lib(encoder.obj) : error LNK2019: unresolved
external symbol _x264_lookahead_delete referenced in function
_x264_encoder_close

1>libx264.lib(analyse.obj) : error LNK2019: unresolved
external symbol _log2f referenced in function _x264_analyse_init_costs

1>bin/x264.exe : fatal error LNK1120: 6 unresolved
externals

         这是因为:libx264工程没有添加lookahead.c文件,从而缺少几个函数的定义造成的,添加lookahead.c进工程;

再次Build libx264工程,修改以下几个错误

  • 1>..\..\encoder\lookahead.c(135) : error C2143: syntax
    error : missing ‘;’ before ‘type’
  • 1>..\..\encoder\lookahead.c(154) : error C2275: ‘x264_t’ :
    illegal use of this type as an expression
  • 1>..\..\encoder\lookahead.c(259) : error C2143: syntax error
    : missing ‘;’ before ‘type’

然后接续编译:

  • 1>libx264.lib(analyse.obj) : error LNK2019: unresolved
    external symbol _log2f referenced in function _x264_analyse_init_costs

这是因为没有定义log2f函数,添加#define
log2f(x) (logf(x)*1.4426950408889634f)到osdep.h中

再次编译x264 成功;

原文地址:https://www.cnblogs.com/cplusplus/p/2451873.html