Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
totaam opened this issue Mar 6, 2013 · 8 comments
Closed

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

totaam opened this issue Mar 6, 2013 · 8 comments

Comments

@totaam
Copy link
Collaborator

totaam commented Mar 6, 2013

Issue migrated from trac ticket # 281

component: platforms | priority: major | resolution: fixed

2013-03-06 07:47:46: antoine created the issue


This will:

  • cleanup the code from all those ifdefs, making it cleaner and easier to read
  • allow the xpra shadow server to run on win32 with x264 encoding

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'
(...)
@totaam
Copy link
Collaborator Author

totaam commented Mar 6, 2013

2013-03-06 07:48:31: antoine uploaded file x264-ifdef-encoder-win32-v3.patch (5.5 KiB)

cleanup, remove ifdefs and allow x264 encoding on win32

@totaam
Copy link
Collaborator Author

totaam commented Mar 6, 2013

2013-03-06 07:53:05: antoine edited the issue description

@totaam
Copy link
Collaborator Author

totaam commented Mar 6, 2013

2013-03-06 08:23:35: antoine uploaded file x264-ifdef-encoder-win32-v4.patch (8.0 KiB)

updated patch that builds ok but does not link on win32

@totaam
Copy link
Collaborator Author

totaam commented Mar 6, 2013

2013-03-06 08:29:54: antoine commented


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

@totaam
Copy link
Collaborator Author

totaam commented Mar 6, 2013

2013-03-06 09:09:33: antoine changed status from new to closed

@totaam
Copy link
Collaborator Author

totaam commented Mar 6, 2013

2013-03-06 09:09:33: antoine changed resolution from ** to fixed

@totaam
Copy link
Collaborator Author

totaam commented Mar 6, 2013

2013-03-06 09:09:33: antoine commented


done in r2867

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

@totaam totaam closed this as completed Mar 6, 2013
@totaam
Copy link
Collaborator Author

totaam commented May 7, 2014

2014-05-07 17:55:11: antoine commented


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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant