[英]Compilation of x264 project
x264 的版本是 148。
对于共享 dll 的编译,我在 MSYS 环境下使用以下命令:
./configure --disable-cli --enable-shared --prefix=.
结果如下:
platform: X86_64
byte order: little-endian
system: WINDOWS
cli: no
libx264: internal
shared: yes
static: no
asm: yes
interlaced: yes
avs: no
lavf: no
ffms: no
mp4: no
gpl: yes
thread: win32
opencl: yes
filters: crop select_every
debug: no
gprof: no
strip: no
PIC: yes
bit depth: 8
chroma format: all
执行make后出现以下错误:
common/win32thread.o:win32thread.c:(.text+0x60): undefined reference to `_beginthreadex'
common/win32thread.o:win32thread.c:(.text+0x60): relocation truncated to fit: R_X86_64_PC32 against undefined symbol `_beginthreadex'
collect2: error: ld returned 1 exit status
Makefile:192: recipe for target 'libx264-148.dll' failed
make: *** [libx264-148.dll] Error 1
我的工作环境:
执行配置命令没有错误,但 make 给了我上述错误。
GCC 由 MSYS2/MinGW 构建,具有不同的配置,并捆绑了不同版本的 MinGW-w64 头文件/库。
因此,需要使用pthreads
库构建 MSYS 应用程序。 您可以强制 x264 的 MSYS 构建使用 posix 线程模型,而不是像这样的 win32 模型:
$ ./configure --disable-cli --enable-shared --disable-win32thread
平台:X86_64
字节顺序:小端
系统:WINDOWS
cli:是的
libx264:内部
共享:是
静态:没有
asm:是的
交错:是
avs:avisynth
拉夫:没有
实况调查:没有
mp4:没有
gpl:是的
线程:posix
opencl:没有
过滤器:裁剪 select_every
lto:没有
调试:没有
教授:没有
条:没有
图片:是的
位深:全部
色度格式:全部您现在可以运行“make”或“make fprofiled”。
问题是,没有msys/winpthreads
包,因此您首先需要为 MSYS2 交叉编译pthreads-win32
。
说了这么多,你说
用于编译共享dll
而不是
用于编译 .so 共享库
所以这对我来说似乎是一个 xY 问题。 我认为您应该使用 MSYS 像这样交叉编译 x264:
$ ./configure --host=x86_64-w64-mingw32 --disable-cli --enable-shared --cross-prefix=x86_64-w64-mingw32-
(我也会使用--prefix=/usr/local
,以及--disable-opencl
与 FFmpeg 兼容。
./configure --enable-shared --enable-static --disable-thread
我有同样的问题。 它适用于禁用的线程。
我使用了以下选项:
./configure --disable-cli --enable-shared
但是不想禁用线程,所以,我所做的是像这样修改win32thread.c
:
之前:
#if HAVE_WINRT
/* _beginthreadex() is technically the correct option, but it's only available for Desktop applications.
* Using CreateThread() as an alternative works on Windows Store and Windows Phone 8.1+ as long as we're
* using a dynamically linked MSVCRT which happens to be a requirement for WinRT applications anyway */
#define _beginthreadex CreateThread
#define InitializeCriticalSectionAndSpinCount(a, b) InitializeCriticalSectionEx(a, b, CRITICAL_SECTION_NO_DEBUG_INFO)
#define WaitForSingleObject(a, b) WaitForSingleObjectEx(a, b, FALSE)
#else
#include <process.h>
#endif
之后
#define _beginthreadex CreateThread
#if HAVE_WINRT
#define InitializeCriticalSectionAndSpinCount(a, b) InitializeCriticalSectionEx(a, b, CRITICAL_SECTION_NO_DEBUG_INFO)
#define WaitForSingleObject(a, b) WaitForSingleObjectEx(a, b, FALSE)
#endif
基本上,我用 Windows 的原生CreateThread
替换了_beginthreadex
。 不确定这对 x264 来说是一个大问题,但现在我可以编译了。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.