Xpra: Ticket #281: get the x264 codec to compile on win32 (with encoding bits)

This will:

See patch attached which does not work..

you must include stdint.h or inttypes.h before x264.h

Still appears (and compilation fails) despite the fact that it is there.. I've checked by adding:

#ifdef _MSC_STDINT_H_
#error "not missing _MSC_STDINT_H_"
#endif

And this does fire. The error seems to come from the libx264.h as it gets included from codec.pyx

Build log:

C:\Python27\Python.exe ./setup.py build
(...)
building 'xpra.x264.codec' extension
C:\Program Files\Microsoft Visual Studio 9.0\VC\BIN\cl.exe /c /nologo /Ox /MD /W3 /GS- /DNDEBUG -IE:\xpra\trunk\src\win3
2 -IC:\libav-win32\win32\usr\include -IC:\x264 -IC:\Python27\include -IC:\Python27\PC /Tcxpra/x264\codec.c /Fobuild\temp
.win32-2.7\Release\xpra/x264\codec.obj
codec.c
You must include stdint.h or inttypes.h before x264.h
C:\Program Files\Microsoft Visual Studio 9.0\VC\BIN\cl.exe /c /nologo /Ox /MD /W3 /GS- /DNDEBUG -IE:\xpra\trunk\src\win3
2 -IC:\libav-win32\win32\usr\include -IC:\x264 -IC:\Python27\include -IC:\Python27\PC /Tcxpra/x264/x264lib.c /Fobuild\te
mp.win32-2.7\Release\xpra/x264/x264lib.obj
x264lib.c
You must include stdint.h or inttypes.h before x264.h
C:\libav-win32\win32\usr\include\libavutil/rational.h(55) : error C2054: expected '(' to follow 'inline'
(...)


Wed, 06 Mar 2013 07:48:30 GMT - Antoine Martin: attachment set

cleanup, remove ifdefs and allow x264 encoding on win32


Wed, 06 Mar 2013 07:53:05 GMT - Antoine Martin: description changed


Wed, 06 Mar 2013 08:23:35 GMT - Antoine Martin: attachment set

updated patch that builds ok but does not link on win32


Wed, 06 Mar 2013 08:29:53 GMT - Antoine Martin:

With the v4 patch above and "libx264" added as a library via setup.py:

building 'xpra.x264.codec' extension
C:\Program Files\Microsoft Visual Studio 9.0\VC\BIN\cl.exe /c /nologo /Ox /MD /W3 /GS- /DNDEBUG \
    -IE:\xpra\trunk\src\win32 \
    -IC:\libav-win32\win32\usr\include \
    -IC:\x264 -IC:\Python27\include \
    -IC:\Python27\PC /Tcxpra/x264\codec.c \
    /Fobuild\temp.win32-2.7\Release\xpra/x264\codec.obj codec.c
C:\Program Files\Microsoft Visual Studio 9.0\VC\BIN\cl.exe /c /nologo /Ox /MD /W3 /GS- /DNDEBUG \
    -IE:\xpra\trunk\src\win32 \
    -IC:\libav-win32\win32\usr\include \
    -IC:\x264 -IC:\Python27\include \
    -IC:\Python27\PC /Tcxpra/x264/x264lib.c \
    /Fobuild\temp.win32-2.7\Release\xpra/x264/x264lib.obj x264lib.c
xpra/x264/x264lib.c(567) : warning C4013: 'round' undefined; assuming extern returning int
C:\Program Files\Microsoft Visual Studio 9.0\VC\BIN\link.exe /DLL /nologo /INCREMENTAL:NO \
    /LIBPATH:C:\Python27\libs \
    /LIBPATH:C:\Python27\PCbuild
    libx264.lib swscale.lib avcodec.lib avutil.lib \
    /EXPORT:initcodec build\temp.win32-2.7\Release\xpra/x264\codec.obj \
    build\temp.win32-2.7\Release\xpra/x264/x264lib.obj \
    /OUT:build\lib.win32-2.7\xpra\x264\codec.pyd \
    /IMPLIB:build\temp.win32-2.7\Release\xpra/x264\codec.lib \
    /MANIFESTFILE:build\temp.win32-2.7\Release\xpra/x264\codec.pyd.manifest \
    /LIBPATH:C:\libav-win32\win32\usr\lib \
    /LIBPATH:C:\libav-win32\win32\usr\bin /OPT:NOREFLINK : \
fatal error LNK1181: cannot open input file 'libx264.lib'
error: command '"C:\Program Files\Microsoft Visual Studio 9.0\VC\BIN\link.exe"' failed with exit status 1181

If I remove "libx264" from setup.py:

C:\Program Files\Microsoft Visual Studio 9.0\VC\BIN\link.exe /DLL /nologo /INCREMENTAL:NO \
    /LIBPATH:C:\Python27\libs \
    /LIBPATH:C:\Python27\PCbuild \
    swscale.lib avcodec.lib avutil.lib \
    /EXPORT:initcodec \
    build\temp.win32-2.7\Release\xpra/x264\codec.obj build\temp.win32-2.7\Release\xpra/x264/x264lib.obj \
    /OUT:build\lib.win32-2.7\xpra\x264\codec.pyd \
    /IMPLIB:build\temp.win32-2.7\Release\xpra/x264\codec.lib \
    /MANIFESTFILE:build\temp.win32-2.7\Release\xpra/x264\codec.pyd.manifest \
    /LIBPATH:C:\libav-win32\win32\usr\lib \
    /LIBPATH:C:\libav-win32\win32\usr\bin /OPT:NOREF
Creating library build\temp.win32-2.7\Release\xpra/x264\codec.lib and object build\temp.win32-2.7\Release\xpra/x264\codec.exp
x264lib.obj : error LNK2019: unresolved external symbol _x264_encoder_open_129 referenced in function _do_init_encoder
x264lib.obj : error LNK2019: unresolved external symbol _x264_param_apply_profile referenced in function _do_init_encoder
x264lib.obj : error LNK2019: unresolved external symbol _x264_param_default_preset referenced in function _do_init_encoder
x264lib.obj : error LNK2019: unresolved external symbol _x264_encoder_close referenced in function _do_clean_encoder
x264lib.obj : error LNK2019: unresolved external symbol _x264_picture_alloc referenced in function _csc_image_rgb2yuv
x264lib.obj : error LNK2019: unresolved external symbol _x264_picture_clean referenced in function _free_csc_image
x264lib.obj : error LNK2019: unresolved external symbol _x264_encoder_encode referenced in function _compress_image
x264lib.obj : error LNK2019: unresolved external symbol _x264_encoder_reconfig referenced in function _set_encoding_speed
x264lib.obj : error LNK2019: unresolved external symbol _x264_encoder_parameters referenced in function _set_encoding_speed
x264lib.obj : error LNK2019: unresolved external symbol _round referenced in function _set_encoding_speed
build\lib.win32-2.7\xpra\x264\codec.pyd : fatal error LNK1120: 10 unresolved externals
error: command '"C:\Program Files\Microsoft Visual Studio 9.0\VC\BIN\link.exe"' failed with exit status 1120

And those symbols can be found in:

$ grep -r x264_encoder_open_129 /cygdrive/c/x264/
Binary file /cygdrive/c/x264/encoder/encoder.o matches
Binary file /cygdrive/c/x264/libx264-129.dll matches
Binary file /cygdrive/c/x264/libx264.a matches
Binary file /cygdrive/c/x264/libx264.dll.a matches
Binary file /cygdrive/c/x264/x264.exe matches
Binary file /cygdrive/c/x264/x264.o matches

Wed, 06 Mar 2013 09:09:33 GMT - Antoine Martin: status changed; resolution set

done in r2867

Note: you will need a libx264.lib, see #270


Wed, 07 May 2014 16:55:10 GMT - Antoine Martin:

As part of #90, I found that cx_freeze picks up the required DLLs from the %PATH%. py2exe cannot because they're not there which is why we already had code to manually add the libx264.dll to the output, the problem is that the libx264.dll builds I have now depend on pthreadGC2.dll too (easily seen with depends.exe once the Encoding_info.exe showed a DLL load error), so r6398 (ugly) tries to find that DLL and bundles it.


Sat, 23 Jan 2021 04:50:28 GMT - migration script:

this ticket has been moved to: https://github.com/Xpra-org/xpra/issues/281