vc2008使用x264的问题
我是采用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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(11)
我建议你先试一试吧,我用mingw编译的dll生成的.a用了有时候会有问题的。
好的,你说的我也试一下,多谢了
哦,通过查看Makefile,才知道默认情况下 output目录下.o 和input下.o文件不会被编译到libx264.a或者libx264.dll.a中,只是在编译x264.exe时才会编译进来。
所以如果是自己的测试程序要用到output或者input, 一定要修改这几个文件,使得它们支持c++编译。
引用来自“bastetwang”的答案
那个msys编译的.a不能直接被vc用,你要用
lib /export:***.def 来生成那个.lib文件。
mp4_output没有编译进你的dll, 检查mp4_output实现是在哪个库, 把代码或库加进来.
另外, 我没记错的话, 你应该在设置宏MP4_OUTPUT和AVIS_INPUT, 才会正常引入它们对应的头文件.
引用来自“Jack.arain”的答案
晕, 怎么不看输出的错误信息呢?
既然输出为mp4, 显然x264不能完成mp4的封装功能, 还需要一个库 gpac, x264只能作编码...
mingw编译的.a一般都可以用于vc, 可能会有些警告.
那个msys编译的.a不能直接被vc用,你要用
lib /export:***.def 来生成那个.lib文件。
晕, 怎么不看输出的错误信息呢?
既然输出为mp4, 显然x264不能完成mp4的封装功能, 还需要一个库 gpac, x264只能作编码...
项目里设置
lib库