把libx264.lib拷到当前工程目录下,并把extrasextras文件夹拷过来
#pragma comment(lib, "libx264.lib")
#include "extras/stdint.h"
#include "x264.h"
如果没有#include "extras/stdint.h"
编译会提示如下
You must include stdint.h or inttypes.h before x264.h
d:\client\x264.h(161) : error C2146: syntax error : missing ';' before identifier 'cqm_4iy'
d:\client\x264.h(161) : error C2501: 'uint8_t' : missing storage-class or type specifiers
d:\client\x264.h(161) : error C2501: 'cqm_4iy' : missing storage-class or type specifiers
d:\client\x264.h(162) : error C2146: syntax error : missing ';' before identifier 'cqm_4ic'
d:\client\x264.h(162) : error C2501: 'uint8_t' : missing storage-class or type specifiers
d:\client\x264.h(162) : error C2501: 'cqm_4ic' : missing storage-class or type specifiers
d:\client\x264.h(163) : error C2146: syntax error : missing ';' before identifier 'cqm_4py'
d:\client\x264.h(163) : error C2501: 'uint8_t' : missing storage-class or type specifiers
d:\client\x264.h(163) : error C2501: 'cqm_4py' : missing storage-class or type specifiers
d:\client\x264.h(164) : error C2146: syntax error : missing ';' before identifier 'cqm_4pc'
d:\client\x264.h(164) : error C2501: 'uint8_t' : missing storage-class or type specifiers
d:\client\x264.h(164) : error C2501: 'cqm_4pc' : missing storage-class or type specifiers
d:\client\x264.h(165) : error C2146: syntax error : missing ';' before identifier 'cqm_8iy'
d:\client\x264.h(165) : error C2501: 'uint8_t' : missing storage-class or type specifiers
d:\client\x264.h(165) : error C2501: 'cqm_8iy' : missing storage-class or type specifiers
d:\client\x264.h(166) : error C2146: syntax error : missing ';' before identifier 'cqm_8py'
d:\client\x264.h(166) : error C2501: 'uint8_t' : missing storage-class or type specifiers
d:\client\x264.h(166) : error C2501: 'cqm_8py' : missing storage-class or type specifiers
d:\client\x264.h(282) : error C2143: syntax error : missing ';' before '*'
d:\client\x264.h(282) : error C2501: 'uint8_t' : missing storage-class or type specifiers
d:\client\x264.h(282) : error C2501: 'plane' : missing storage-class or type specifiers
d:\client\x264.h(293) : error C2146: syntax error : missing ';' before identifier 'i_pts'
d:\client\x264.h(293) : error C2501: 'int64_t' : missing storage-class or type specifiers
d:\client\x264.h(293) : error C2501: 'i_pts' : missing storage-class or type specifiers
d:\client\x264.h(341) : error C2143: syntax error : missing ';' before '*'
d:\client\x264.h(341) : error C2501: 'uint8_t' : missing storage-class or type specifiers
d:\client\x264.h(341) : error C2501: 'p_payload' : missing storage-class or type specifiers
D:\Client\ClientDlg.cpp(306) : warning C4244: '=' : conversion from 'long' to 'unsigned short', possible loss of data
实际上,x264源文件中,我并没有搜索到inttypes.h,只是在extras文件夹下有stdint.h
stdint.h中的内容都是一些typedef语句,形如下面之类:
/* 7.18.1.1 Exact-width integer types */
typedef signed char int8_t;
typedef unsigned char uint8_t;
typedef short int16_t;
typedef unsigned short uint16_t;
typedef int int32_t;
typedef unsigned uint32_t;
typedef __int64 int64_t;
typedef unsigned __int64 uint64_t;
在本文开始编译时有一句提示“You must include stdint.h or inttypes.h before x264.h”,这个在x264中的对应代码为:
#if !defined(_STDINT_H) && !defined(_STDINT_H_) && \
!defined(_INTTYPES_H) && !defined(_INTTYPES_H_)
# ifdef _MSC_VER
# pragma message("You must include stdint.h or inttypes.h before x264.h")
# else
# warning You must include stdint.h or inttypes.h before x264.h
# endif
#endif
在stdint.h中的对应代码为:
#ifndef _STDINT_H
#define _STDINT_H
#define __need_wint_t
#define __need_wchar_t
这样你就可以在程序中定义x264.h里的类型了:
#pragma comment(lib, "libx264.lib")
#include "extras/stdint.h"
#include "x264.h"
... ...
void CClientDlg::OnBtnStartcap()
{
// TODO: Add your control notification handler code here
x264_param_t dsds;//x264.h里的一种数据类型
}
评论