【问题标题】:Compilation of x264 projectx264项目编译
【发布时间】:2016-06-11 00:28:20
【问题描述】:

我已经下载了source of x264 library

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. Windows 10 专业版
  2. MSYS64 和 mingw64
  3. Microsoft Visual Studio 2015

configure 命令执行没有错误,但是 make 给了我上面描述的错误。

【问题讨论】:

  • 很奇怪。 process.hWinGW 的一部分。你可以试试make -D__MSVCRT__
  • 尊敬的蒂姆先生,非常感谢您的回答。目标是在 GCC 环境中构建 DLL。选项 make -D__MSVCRT__ 与 MSVC 环境有关。命令 $ make -D__MSVCRT__ 给出错误 make: invalid option -- D make: invalid option -- _ make: invalid option -- _ make: invalid option -- M make: invalid option -- V 用法:make [options] [目标] ...

标签: c++ gcc mingw msys


【解决方案1】:

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

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

因此,MSYS 应用程序需要使用pthreads 库构建。您可以强制 x264 的 MSYS 构建使用 posix 线程模型,而不是像这样的 win32 模型:

$ ./configure --disable-cli --enable-shared --disable-win32thread

平台:X86_64
字节顺序:小端序
系统:WINDOWS
cli:是的
libx264:内部
共享:是的
静态:无
asm:是的
隔行扫描:是
avs: avisynth
lavf: 没有
实况调查团:没有
mp4:没有
gpl:是的
线程:posix
opencl:没有
过滤器:裁剪 select_ever
lto: 没有
调试:没有
gprof:没有
脱衣舞:没有
图片:是的
位深:全部
色度格式:全部

您现在可以运行“make”或“make fprofiled”。

问题是,没有msys/winpthreads 包,所以你首先需要为MSYS2 交叉编译pthreads-win32


说了这么多,你说

用于编译共享 dll

而不是

用于编译 .so 共享库

所以这对我来说似乎是一个 x-Y 问题。我认为您应该像这样使用 MSYS 来交叉编译 x264:

$ ./configure --host=x86_64-w64-mingw32 --disable-cli --enable-shared --cross-prefix=x86_64-w64-mingw32-

(我也会使用--prefix=/usr/local--disable-opencl 来与FFmpeg 兼容。

【讨论】:

    【解决方案2】:
    ./configure --enable-shared --enable-static --disable-thread
    

    我遇到了同样的问题。它适用于禁用的线程。

    【讨论】:

    • 治标不治本;现在 x264 将被限制为单个线程!
    【解决方案3】:

    我使用了以下选项:

    ./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
    

    基本上,我将_beginthreadex 替换为Windows 原生的CreateThread。不确定这对 x264 来说是个大问题,但现在我可以编译了。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2013-10-02
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-07-16
      相关资源
      最近更新 更多