2013-11-02 819 views
0

我正在构建使用x264作为静态库的自定义视频编码器。我遵循this指南来建立静态库。试图编译此:无法与libx264.lib静态库链接

x264_t * setup_encoder(int width, int height){ 
    x264_param_t param; 
    x264_param_default_preset(&param, "veryfast", "zerolatency"); 
    param.i_threads = 1; 
    param.i_width = width; 
    param.i_height = height; 
    param.i_fps_num = 26; 
    param.i_fps_den = 1; 
    // Intra refres: 
    param.i_keyint_max = 26; 
    param.b_intra_refresh = 1; 
    //Rate control: 
    param.rc.i_rc_method = X264_RC_CRF; 
    param.rc.f_rf_constant = 25; 
    param.rc.f_rf_constant = 25; 
    param.rc.f_rf_constant_max = 35; 
    //For streaming: 
    param.b_repeat_headers = 1; 
    param.b_annexb = 1; 
    x264_param_apply_profile(&param, "baseline"); 

    return x264_encoder_open(&param); 
} 

结果:

main.obj:错误LNK2019:解析外部符号 “INT __cdecl x264_param_default_preset(结构x264_param_t *,字符常量*,字符常量*)”

main.obj:错误LNK2019:解析外部符号 “INT __cdecl x264_param_apply_profile(结构x264_param_t *,字符常量*)”

main.obj:错误LNK2019:解析的外部符号“ST构作x264_t * __cdecl x264_encoder_open_136(结构x264_param_t *)”

%PROJECT_DIR%:致命错误LNK1120:3无法解析的外部

链接扫描libx264.lib,但无法找到里面的任何东西。

Searching .\lib\libx264.lib: 

随着dumpbin/HEADERS我实际上可以找到我需要的声明,但链接器无法做到这一点。

SECTION HEADER #38 
    .text name 
     0 physical address 
     0 virtual address 
    E60 size of raw data 
    930C file pointer to raw data (0000930C to 0000A16B) 
    D219 file pointer to relocation table 
     0 file pointer to line numbers 
     40 number of relocations 
     0 number of line numbers 
60501020 flags 
     Code 
     COMDAT; sym= x264_param_default_preset 
     16 byte align 
     Execute Read 

环境是Visual Studio 2012与Windows 8 64位上的英特尔编译器14。

回答

2

尝试使用包括使用C风格的绑定。

extern "C" { 
#include <x264.h> 
} 
+0

获取多个函数的多个定义(在libcmt.lib中),所以无法连接。你的代码是如何工作的? –

+0

http://en.wikipedia.org/wiki/Name_mangling – szatmary