VS2019下编译x264.dll

一.安装MSYS2

  • 官网地址:MSYS2
  • 64位选择x86_64版本,直接install就行

二. 在MSYS2中安装MinGW

  • Update the package database and core system packages
pacman -Syu
pacman -Su
  • 安装32位版本和64位版本的工具链
pacman -S mingw-w64-i686-gcc
pacman -S mingw-w64-x86_64-gcc
  • install some others important
pacman -S base-devel
pacman -S vim
pacman -S nasm
pacman -S git

安装完成之后,在开始菜单的目录会出现:“MSYS2 MinGW x86”以及“MSYS2 MinGW x64”,可以gcc -v查看是否出现提示信息

三.下载x264

  • videoLAN:VLC
  • 解压到MSYS2安装目录的home目录下

四.build

  • 打开MSYS2 MinGW x64 ,cd到上述home下x264所在目录
MINGW64 /home/x264-master/x264-master
$  
  • set configure ,需要build .dll出来
./configure --host=x86_64-w64-mingw32 --enable-shared --disable-cli
  • make
make

编译完毕后,在x264所在目录会生成libx264-164.dll

五.VS2019创建一个x64的控制台工程

  • 有关创建x86 or x64控制台工程的问题可参考:百度百科
  • 将libx264-164.dll copy到此工程的工作目录下

六.将.dll->.lib

pexports libx264-164.dll > libx264-164.def  
LIB /machine:X64 /DEF:libx264-164.def 
  • 配置依赖库
    在链接器:输入->附加依赖项中,添加libx264-164.lib

七. 测试库是否正确

#include <iostream>
#include <string>
#include "stdint.h"  
#pragma comment(lib, "libx264-164.lib")
extern "C"
{
#include "x264.h"
#include "x264_config.h"
};
using namespace std;
 
int main(int argc, char **argv)
{
	x264_param_t param;
	x264_param_default(&param);
	cout << "hello,x264" << endl;
	return 0;
}

output:

hello,x264

D:\VS2019\SourceCode\x264\hello_x264\x64\Debug\hello_x264.exe (进程 16888)已退出,代码为 0。
要在调试停止时自动关闭控制台,请启用“工具”->“选项”->“调试”->“调试停止时自动关闭控制台”。
按任意键关闭此窗口. . .

参考文章:
1. windows下编译64位x264
2.【X265】Win10环境编译x264 / x265,调用libx264 / libx265

评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值