1、从github上下载libx264的源码,如果是压缩包下载的,解压,例如解压后的目录C:\Users\Administrator\Downloads\x264-master\x264-master。
2、安装MinGW,然后进入msys\1.0目录,找到msys.bat,双击运行,然后进入C:\Users\Administrator\Downloads\x264-master\x264-master目录。
3、运行 ./configure --enable-shared,会出现一个提示,
Found no assembler
Minimum version is nasm-2.13
If you really want to compile without asm, configure with --disable-asm.
在上面的命令后面加上--disable-asm,运行./configure --enable-shared --disable-asm
platform: X86
byte order: little-endian
system: WINDOWS
cli: yes
libx264: internal
shared: yes
static: no
bashcompletion: no
asm: no
interlaced: yes
avs: avisynth
lavf: no
ffms: no
mp4: no
gpl: yes
thread: win32
opencl: yes
filters: crop select_every
lto: no
debug: no
gprof: no
strip: no
PIC: no
bit depth: all
chroma format: all
接下来再运行make命令,就可以生成libx264-164.dll,这个时候只是生成了dll。
4、运行Visual Studio 2015 本机命令行工具提示符程序(对应自己的VS安装版本,Visual Studio 2019也同样),进入到生成的dll所在目录。
有些说用pexports libx264-164.dll > libx264-164.def,虽然可以生成def文件,但是我这边会提示
'pexports' 不是内部或外部命令,也不是可运行的程序
或批处理文件。
用dumpbin /exports libx264-164.dll>libx264.def这个命令就正常生成了,
内容如下
Microsoft (R) COFF/PE Dumper Version 14.00.23026.0
Copyright (C) Microsoft Corporation. All rights reserved.
Dump of file libx264-164.dll
File Type: DLL
Section contains the following exports for libx264-164.dll
00000000 characteristics
610CE60F time date stamp Fri Aug 6 15:34:39 2021
0.00 version
1 ordinal base
51 number of functions
51 number of names
ordinal hint RVA name
1 0 000FE920 x264_10_frame_pop
2 1 000FE8F0 x264_10_frame_push
3 2 000FE9D0 x264_10_frame_shift
4 3 000FE980 x264_10_frame_unshift = _sub8x8_dct
5 4 0019CF30 x264_10_threadpool_delete
6 5 0019CC90 x264_10_threadpool_init
7 6 0019CE10 x264_10_threadpool_run
8 7 0019CE60 x264_10_threadpool_wait
9 8 0002F000 x264_8_frame_pop
10 9 0002EFD0 x264_8_frame_push
11 A 0002F0B0 x264_8_frame_shift
12 B 0002F060 x264_8_frame_unshift
13 C 000CC780 x264_8_threadpool_delete
14 D 000CC4E0 x264_8_threadpool_init
15 E 000CC660 x264_8_threadpool_run
16 F 000CC6B0 x264_8_threadpool_wait
17 10 001AD088 x264_chroma_format
18 11 00007DD0 x264_cpu_detect
19 12 001A93C0 x264_cpu_names
20 13 00007DE0 x264_cpu_num_processors
21 14 00007F40 x264_encoder_close
22 15 00008050 x264_encoder_delayed_frames
23 16 00008010 x264_encoder_encode
24 17 00007FE0 x264_encoder_headers
25 18 00008090 x264_encoder_intra_refresh
26 19 000080B0 x264_encoder_invalidate_reference = _mc_copy_w8
27 1A 00008070 x264_encoder_maximum_delayed_frames
28 1B 00007DF0 x264_encoder_open_164
29 1C 00007FC0 x264_encoder_parameters
30 1D 00007FA0 x264_encoder_reconfig
31 1E 00001AC0 x264_free
32 1F 001ACDC0 x264_levels
33 20 00001800 x264_log_default
34 21 000019C0 x264_log_internal
35 22 00001A20 x264_malloc
36 23 000012E0 x264_mdate
37 24 00007F70 x264_nal_encode
38 25 00007230 x264_param2string = _x264_pthread_mutex_lock
39 26 00003130 x264_param_apply_fastfirstpass
40 27 000031A0 x264_param_apply_profile
41 28 00001D70 x264_param_cleanup
42 29 00002100 x264_param_default
43 2A 00002840 x264_param_default_preset
44 2B 000034B0 x264_param_parse
45 2C 00001E00 x264_picture_alloc
46 2D 000020B0 x264_picture_clean
47 2E 00001DC0 x264_picture_init
48 2F 00001860 x264_reduce_fraction
49 30 000018C0 x264_reduce_fraction64
50 31 00001AE0 x264_slurp_file
51 32 00001320 x264_threading_init
Summary
1000 .CRT
FA000 .bss
1000 .data
1000 .debug_abbrev
1000 .debug_aranges
1000 .debug_frame
2000 .debug_info
1000 .debug_line
1000 .edata
15000 .eh_frame
1000 .idata
23000 .rdata
6000 .reloc
1000 .rsrc
1A6000 .text
1000 .tls
然后再执行lib /def:libx264.def /machine:x64 /out:libx264.lib,这个时候生成了lib文件(1.5kb,感觉不太正常),有些说要用标准的def文件,故改成下面
LIBRARY
EXPORTS
x264_10_frame_pop
x264_10_frame_push
x264_10_frame_shift
x264_10_frame_unshift = _sub8x8_dct
x264_10_threadpool_delete
x264_10_threadpool_init
x264_10_threadpool_run
x264_10_threadpool_wait
x264_8_frame_pop
x264_8_frame_push
x264_8_frame_shift
x264_8_frame_unshift
x264_8_threadpool_delete
x264_8_threadpool_init
x264_8_threadpool_run
x264_8_threadpool_wait
x264_chroma_format
x264_cpu_detect
x264_cpu_names
x264_cpu_num_processors
x264_encoder_close
x264_encoder_delayed_frames
x264_encoder_encode
x264_encoder_headers
x264_encoder_intra_refresh
x264_encoder_invalidate_reference = _mc_copy_w8
x264_encoder_maximum_delayed_frames
x264_encoder_open_164
x264_encoder_parameters
x264_encoder_reconfig
x264_free
x264_levels
x264_log_default
x264_log_internal
x264_malloc
x264_mdate
x264_nal_encode
x264_param2string = _x264_pthread_mutex_lock
x264_param_apply_fastfirstpass
x264_param_apply_profile
x264_param_cleanup
x264_param_default
x264_param_default_preset
x264_param_parse
x264_picture_alloc
x264_picture_clean
x264_picture_init
x264_reduce_fraction
x264_reduce_fraction64
x264_slurp_file
x264_threading_init
再执行lib /def:libx264.def /machine:x64 /out:libx264.lib,生成的lib文件13KB大了很多,感觉正常些。