我从网站
下载了x264库的源代码http://www.videolan.org/developers/x264.html
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
我的工作环境:
Windows 10 Pro
MSYS64 with mingw64
Microsoft Visual Studio 2015
非常感谢您的帮助
最诚挚的问候,
Vladimir Kharam
configure命令执行时没有错误,但make给出了上述错误。
答案 0 :(得分:1)
./configure --enable-shared --enable-static --disable-thread
我遇到了同样的问题。它适用于禁用的线程。
答案 1 :(得分:0)
GCC由具有不同配置的MSYS2 / MinGW构建,并捆绑了不同版本的MinGW-w64标头/库。
因此,需要使用pthreads
库来构建MSYS应用程序。您可以强制x264的MSYS构建使用posix线程模型,而不是win32模型,如下所示:
$ ./configure --disable-cli --enable-shared --disable-win32thread
平台:X86_64
字节顺序:little-endian
系统:WINDOWS
cli:是
libx264:内部
分享:是的
静态:否
汇编:是的
隔行扫描:是
avs:avisynth
lavf:否
ffms:否
mp4:否
gpl:是的
线程:posix
opencl:否
筛选器:裁剪select_every
lto:否
调试:否
gprof:否
剥离:否
PIC:是的
位深度:全部
色度格式:全部您现在可以运行“ 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-
(为了与FFmpeg兼容,我还将使用--prefix=/usr/local
和--disable-opencl
。
答案 2 :(得分:0)
我使用了以下选项:
./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的本机_beginthreadex
取代了CreateThread
。不确定对于x264来说这是一个大问题,但是现在我可以编译了。