C++ x264项目的编制

C++ x264项目的编制,c++,gcc,mingw,msys,C++,Gcc,Mingw,Msys,我已经下载了 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:

我已经下载了

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
我的工作环境:

./configure --disable-cli --enable-shared --prefix=.
  • Windows10Pro
  • 带有mingw64的MSYS64
  • Microsoft Visual Studio 2015
  • configure命令执行时没有错误,但是make给出了上述错误

    ./configure --enable-shared --enable-static --disable-thread
    

    我也有同样的问题。它与禁用的线程一起工作。

    GCC由MSYS2/MinGW以不同的配置构建,并与不同版本的MinGW-w64 Header/libs捆绑在一起

    • MSYS2只提供posix线程模型(pthreads);i686的侏儒,x86_64的seh
    • 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:否
    ffms:否
    mp4:否
    gpl:是
    线程:posix
    opencl:否
    过滤器:裁剪选择\u每一次
    lto:否
    调试:否
    gprof:否
    条带:否
    图片:是的
    位深度:全部
    色度格式:全部

    现在可以运行“make”或“make fprofile”

    问题是,没有
    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-
    

    (我还将使用
    --前缀=/usr/local
    ,以及
    --禁用opencl
    ,以与FFmpeg兼容。

    我使用了以下选项:

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

    基本上,我用Windows的native
    CreateThread
    替换了
    \u beginthreadex
    。我不确定这对x264来说是个大问题,但现在我可以编译了。

    怪异的.process.h是其中的一部分。你可以试试
    make-D_umsvcrt\uuu
    。亲爱的Tim先生,非常感谢你的回答。目标是在GCC环境中构建DLL。选项make-D_uumsvcrt_uu与MSVC环境相关。命令$make-D_umsvcrt_uu给出错误make:invalid选项--D make:invalid选项--uu make:invalid选项--M make:invalid选项--V用法:make[options][target V]…它处理症状,但不处理问题;现在x264将被限制为单个线程!