繁体   English   中英

x264项目编译

[英]Compilation of x264 project

我已经下载了x264 库源代码

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

我的工作环境:

  1. 视窗 10 专业版
  2. MSYS64 与 mingw64
  3. 微软 Visual Studio 2015

执行配置命令没有错误,但 make 给了我上述错误。

GCC 由 MSYS2/MinGW 构建,具有不同的配置,并捆绑了不同版本的 MinGW-w64 头文件/库。

  • MSYS2只提供posix线程模型(pthreads); i686 的侏儒,x86_64 的 seh。
  • MinGW提供posix和win32线程模型; sjlj 和 dwarf 用于 i686,seh 和 sjlj 用于 x86_64。

因此,需要使用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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM