ChinaFFmpeg

 找回密码
 立即注册

QQ登录

只需一步,快速开始

查看: 12430|回复: 2

[Windows] 无法解析的外部符号 "void __cdecl av_register_all()"

[复制链接]
发表于 2013-10-5 21:30:13 | 显示全部楼层 |阅读模式
代码如下(windows + visual studio 2010):
[C++] 纯文本查看 复制代码
#include <iostream>
using namespace std;

#ifdef _cplusplus 
extern "C" {
#endif

#include "libavcodec\avcodec.h"
#include "libavformat\avformat.h"

#ifdef _cplusplus
}
#endif

int main()
{
	av_register_all();
	return 0;
}








我用的lib和dll文件都是从C:\msys\1.0\local\bin目录下的。


本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有帐号?立即注册

x
回复

使用道具 举报

发表于 2013-10-5 21:35:59 | 显示全部楼层
C++中调用C的函数时,需要使用extern "C"来声明,这样编译器就会生成对应的指令规则
可以考虑用extern "C" 来包含,例如

extern "C"
{
#include "libavutil/avutil.h"
#include "libavformat/avformat.h"
#include "libavdevice/avdevice.h"
#include "libavcodec/avcodec.h"
}
回复 支持 1 反对 0

使用道具 举报

 楼主| 发表于 2013-10-5 21:35:31 | 显示全部楼层
头文件引用改成如下就可以了
extern "C" {
#include "libavcodec\avcodec.h"
}


extern "C" {
#include "libavformat\avformat.h"
}
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

手机版|Archiver|ChinaFFmpeg

GMT+8, 2024-4-26 21:35 , Processed in 0.062013 second(s), 17 queries .

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表