分享

x264代码剖析(四):vs2010编译x264错误集锦

 托尼虎 2018-12-25

        支持VC++平台的x264的最新版本是x264-20091006,接下来就以该版本为例分析编译运行x264过程中遇到的问题以及解决办法。

 

1error C2143: syntax error : missing ';' before 'type'

 

错误提示:



错误原因:MSVS编译器对C99标准支持不好,不支持函数当中混合定义、声明变量。

解决办法:在函数开头统一定义变量。

 

示例源码:

  1. static ALWAYS_INLINE int x264_exp2fix8( float x )
  2. {
  3. if( x >= 512.f/6.f ) return 0;
  4. if( x <= -512.f/6.f ) return 0xffff;
  5. int i = x*(-64.f/6.f) + 512;
  6. return (x264_exp2_lut[i&63]+256) << (i>>6) >> 8;
  7. }

修改后代码:

  1. static ALWAYS_INLINE int x264_exp2fix8( float x )
  2. {
  3. int i;
  4. if( x >= 512.f/6.f ) return 0;
  5. if( x <= -512.f/6.f ) return 0xffff;
  6. i = x*(-64.f/6.f) + 512;
  7. return (x264_exp2_lut[i&63]+256) << (i>>6) >> 8;
  8. }

注:x264代码中有十几处类似的错误,只需一一改正过来就可以了。


2error 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};


3error 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 );


4error LNK2019: unresolved external symbol _x264_lookahead_init referenced in function _x264_encoder_open_76

 

        这是由于libx264工程没有添加lookahead.c文件,从而缺少几个函数的定义造成的,错误提示如下图:


        

         解决方法:添加lookahead.c进工程,如下图所示:




5error LNK2019: unresolved external symbol _log2f referenced in function _x264_analyse_init_costs

 

         解决办法:重新定义一下log2f(x)即可,在osdep.h中添加log2f(x)定义,加入的代码如下:

  1. #ifdef _MSC_VER
  2. #define inline __inline
  3. #define strcasecmp stricmp
  4. #define strncasecmp strnicmp
  5. #define snprintf _snprintf
  6. #define fseek _fseeki64
  7. #define ftell _ftelli64
  8. #define isfinite _finite
  9. #define strtok_r strtok_s
  10. #define _CRT_SECURE_NO_DEPRECATE
  11. #define X264_VERSION "" // no configure script for msvc
  12. #define log2f(x) (logf(x)*1.4426950408889634f)
  13. #endif

       截止目前,应该可以把所有的问题都解决了,出现了大家最喜欢的Build succeeded。大笑


    本站是提供个人知识管理的网络存储空间,所有内容均由用户发布,不代表本站观点。请注意甄别内容中的联系方式、诱导购买等信息,谨防诈骗。如发现有害或侵权内容,请点击一键举报。
    转藏 分享 献花(0

    0条评论

    发表

    请遵守用户 评论公约

    类似文章 更多