vc2008使用x264的问题

发布于 2021-11-05 05:49:48 字数 2305 浏览 843 评论 11

我是采用msys编译的x264,编译出libx264.dll.a 和libx264-78.dll。 我用vs2008做了一个测试程序,也对x264.h做的extern “C"的说明,但还是有link错误,我的错误是:

1>Linking...

1>libx264.dll.a(d000112.o) : warning LNK4078: multiple '.text' sections found with different attributes (E0300020)

1>x264_test.obj : error LNK2001: unresolved external symbol _thread_input

1>x264_test.obj : error LNK2001: unresolved external symbol _mp4_output

1>x264_test.obj : error LNK2001: unresolved external symbol _avis_input

我贴出代码前面部分:

#include <stdlib.h>
#include <math.h>

#ifndef __GNUC__
# define __attribute__(x) /*NOTHING*/
#endif

#define _GNU_SOURCE
#include <getopt.h>

extern "C"  {
#include "common/common.h"
#include "common/cpu.h"
#include "x264.h"
#include "muxers.h"
#include "config.h"
}

typedef struct {
    int _progress;
    int _seek;
    hnd_t hin;
    hnd_t hout;
    int i_seek;
    int b_progress;
    FILE * _file;
}cli_opt_t;

cli_input_t input;
cli_output_t output;

#include <windows.h>

#pragma comment(lib, "libx264.dll.a")

static int init_param(x264_param_t * param, cli_opt_t *opt);
static int encode(x264_param_t* param, cli_opt_t *opt);
static int encode_frame(x264_t* h, hnd_t hout, x264_picture_t * pic);
static void print_status( int64_t i_start, int i_frame, int i_frame_total, int64_t i_file, x264_param_t *param );

int main(int argc, char** argv)
{
    x264_param_t param;
    cli_opt_t opt;
    int ret;

    x264_param_default(¶m);
    init_param(¶m, &opt);
   
    input = avis_input;
    output = mp4_output;

    int fps_num = param.i_fps_num;
    int fps_den = param.i_fps_den;
   
    if(input.open_file(argv[1], &opt.hin, ¶m)) {
        printf("cound not open input file '%s'n", argv[1]);
        return -1;
    }
    if(output.open_file(argv[2], &opt.hout)) {
        printf("cound not open output file '%s'n", argv[2]);
        return -1;
    }
   
    if(param.i_threads > 1 && x264_cpu_num_processors() > 1) {
        if(thread_input.open_file(NULL, &opt.hin, ¶m) == 0) {
            input = thread_input;
        }
    }
    ret = encode(¶m, &opt);
   
    return 0;
} 

请高手指教这个link错误如何改正,先多谢了..

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(11

深巷少女 2021-11-08 21:56:22

我建议你先试一试吧,我用mingw编译的dll生成的.a用了有时候会有问题的。

惜醉颜 2021-11-08 21:56:22

好的,你说的我也试一下,多谢了

醉生梦死 2021-11-08 21:56:22

哦,通过查看Makefile,才知道默认情况下 output目录下.o 和input下.o文件不会被编译到libx264.a或者libx264.dll.a中,只是在编译x264.exe时才会编译进来。

所以如果是自己的测试程序要用到output或者input, 一定要修改这几个文件,使得它们支持c++编译。

清风夜微凉 2021-11-08 21:56:18

引用来自“bastetwang”的答案

那个msys编译的.a不能直接被vc用,你要用

lib /export:***.def 来生成那个.lib文件。

浅沫记忆 2021-11-08 21:56:15

mp4_output没有编译进你的dll, 检查mp4_output实现是在哪个库, 把代码或库加进来.

浮生未歇 2021-11-08 21:56:13

另外, 我没记错的话, 你应该在设置宏MP4_OUTPUT和AVIS_INPUT, 才会正常引入它们对应的头文件.

最偏执的依靠 2021-11-08 21:56:05

引用来自“Jack.arain”的答案

晕,  怎么不看输出的错误信息呢? 

既然输出为mp4, 显然x264不能完成mp4的封装功能, 还需要一个库 gpac, x264只能作编码...

猫烠⑼条掵仅有一顆心 2021-11-08 21:55:57

mingw编译的.a一般都可以用于vc, 可能会有些警告.

酒几许 2021-11-08 20:56:42

那个msys编译的.a不能直接被vc用,你要用

lib /export:***.def 来生成那个.lib文件。

如此安好 2021-11-08 11:39:14

晕,  怎么不看输出的错误信息呢? 

既然输出为mp4, 显然x264不能完成mp4的封装功能, 还需要一个库 gpac, x264只能作编码...

月亮是我掰弯的 2021-11-07 18:07:20

项目里设置
lib库

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文