c++ - 无法与 libx264.lib 静态库链接

标签 c++ visual-studio-2012 linker libx264

我正在使用 x264 作为静态库构建自定义视频编码器。我关注了this指南以构建静态库。试图编译这个:

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 : error LNK2019: unresolved external symbol "int __cdecl x264_param_default_preset(struct x264_param_t *,char const *,char const *)"

main.obj : error LNK2019: unresolved external symbol "int __cdecl x264_param_apply_profile(struct x264_param_t *,char const *)"

main.obj : error LNK2019: unresolved external symbol "struct x264_t * __cdecl x264_encoder_open_136(struct x264_param_t *)"

%PROJECT_DIR%: fatal error LNK1120: 3 unresolved externals

链接器扫描 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 和 Intel Compiler 14 on Windows 8 64-bit。

最佳答案

尝试包括使用 C 样式绑定(bind)。

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

关于c++ - 无法与 libx264.lib 静态库链接,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19744554/

相关文章:

C++ 可执行文件无法在基于 Linux 的托管服务器上运行

c# - 将 ViewModel 中包含的 ObservableCollection 绑定(bind)到 ListView

c++ - 静态库调用访问冲突

c - Visual Studio : Identifider "MSFDTEDIT_CLASS" is undefined

android - 无法加载共享库,因为主要编号作为库依赖项的一部分给出

c++ - 如何从源代码或库中替换 __ieee754_exp_avx 调用?

c++ - 标准实验锁存器和屏障使用 ptrdiff_t

c++ - 你怎么知道客户端何时连接到服务器?

visual-studio-2012 - 如何将值从 MTM 传递到数据驱动编码的 Ui 测试用例?

visual-studio-2012 - InRelease- 与 TFS2012 一起使用的发布管理许可证问题