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

Ctypesgen fails to create bindings on Windows #138

Closed
mara004 opened this issue Feb 19, 2022 · 5 comments
Closed

Ctypesgen fails to create bindings on Windows #138

mara004 opened this issue Feb 19, 2022 · 5 comments

Comments

@mara004
Copy link
Contributor

mara004 commented Feb 19, 2022

I am using ctypesgen to create Python bindings to PDFium, pypdfium2.
While ctypesgen runs perfectly well on my Linux devices, I don't manage to make it work on Windows.
After installing mingw and running my bindings generation script, the resulting file only contains the library loader classes, but no actual bindings. This is the console output:

INFO: Status: Preprocessing D:\tmp\tmpjhnl1dkc.h
INFO: Status: gcc -E -U __GNUC__ -dD "-Dinline=" "-D__inline__=" "-D__extension__=" "-D__const=const" "-D__asm__(x)=" "-D__asm(x)=" "-DCTYPESGEN=1" "D:\tmp\tmpjhnl1dkc.h"
ERROR: D:\tmp\tmpjhnl1dkc.h:0: Scanning error. Illegal character '#'; # 1 "D:\\tmp\\tmpjhnl1dkc.h"
INFO: Status: Parsing D:\tmp\tmpjhnl1dkc.h
INFO: Status: Processing description list.
INFO: Status: Writing to D:\Users\Mara\Downloads\pypdfium2\data\windows_x64\_pypdfium.py.
INFO: Status: Wrapping complete.

This is how ctypesgen is invoked:

ctypesgen --library pdfium --strip-build-path "D:\Users\Mara\Downloads\pypdfium2\data\windows_x64" -L . "D:\Users\Mara\Downloads\pypdfium2\data\windows_x64\build_tar\include\fpdf_annot.h" "D:\Users\Mara\Downloads\pypdfium2\data\windows_x64\build_tar\include\fpdf_attachment.h" "D:\Users\Mara\Downloads\pypdfium2\data\windows_x64\build_tar\include\fpdf_catalog.h" "D:\Users\Mara\Downloads\pypdfium2\data\windows_x64\build_tar\include\fpdf_dataavail.h" "D:\Users\Mara\Downloads\pypdfium2\data\windows_x64\build_tar\include\fpdf_doc.h" "D:\Users\Mara\Downloads\pypdfium2\data\windows_x64\build_tar\include\fpdf_edit.h" "D:\Users\Mara\Downloads\pypdfium2\data\windows_x64\build_tar\include\fpdf_ext.h" "D:\Users\Mara\Downloads\pypdfium2\data\windows_x64\build_tar\include\fpdf_flatten.h" "D:\Users\Mara\Downloads\pypdfium2\data\windows_x64\build_tar\include\fpdf_formfill.h" "D:\Users\Mara\Downloads\pypdfium2\data\windows_x64\build_tar\include\fpdf_fwlevent.h" "D:\Users\Mara\Downloads\pypdfium2\data\windows_x64\build_tar\include\fpdf_javascript.h" "D:\Users\Mara\Downloads\pypdfium2\data\windows_x64\build_tar\include\fpdf_ppo.h" "D:\Users\Mara\Downloads\pypdfium2\data\windows_x64\build_tar\include\fpdf_progressive.h" "D:\Users\Mara\Downloads\pypdfium2\data\windows_x64\build_tar\include\fpdf_save.h" "D:\Users\Mara\Downloads\pypdfium2\data\windows_x64\build_tar\include\fpdf_searchex.h" "D:\Users\Mara\Downloads\pypdfium2\data\windows_x64\build_tar\include\fpdf_signature.h" "D:\Users\Mara\Downloads\pypdfium2\data\windows_x64\build_tar\include\fpdf_structtree.h" "D:\Users\Mara\Downloads\pypdfium2\data\windows_x64\build_tar\include\fpdf_sysfontinfo.h" "D:\Users\Mara\Downloads\pypdfium2\data\windows_x64\build_tar\include\fpdf_text.h" "D:\Users\Mara\Downloads\pypdfium2\data\windows_x64\build_tar\include\fpdf_thumbnail.h" "D:\Users\Mara\Downloads\pypdfium2\data\windows_x64\build_tar\include\fpdf_transformpage.h" "D:\Users\Mara\Downloads\pypdfium2\data\windows_x64\build_tar\include\fpdfview.h" -o "D:\Users\Mara\Downloads\pypdfium2\data\windows_x64\_pypdfium.py"

Steps to reproduce:

git clone "https://github.com/pypdfium2-team/pypdfium2.git"
cd pypdfium2
python3 platform_setup\update_pdfium.py -p windows_x64
@nilason
Copy link
Collaborator

nilason commented Feb 19, 2022

Just to be sure, what version of ctypesgen are you using?

@mara004

This comment was marked as outdated.

@mara004
Copy link
Contributor Author

mara004 commented Feb 20, 2022

I installed ctypesgen from commit cef9a7a.

@mara004
Copy link
Contributor Author

mara004 commented Feb 20, 2022

Oh, updating to the latest commit fd495e5 indeed fixes the issue. Thanks!

@mara004 mara004 closed this as completed Feb 20, 2022
@mara004
Copy link
Contributor Author

mara004 commented Feb 20, 2022

Not sure whether this is of any relevance, but I get the following error messages whilst running ctypesgen on Windows:
(The output file looks correct and my test suite passes, so this seems to be harmless, but maybe it's interesting for developpers)

ERROR: c:\\mingw\\include\\winnt.h:182: Syntax error at 'DWORDLONG'
ERROR: c:\\mingw\\include\\winnt.h:187: Syntax error at '*'
ERROR: c:\\mingw\\include\\basetsd.h:115: Syntax error at 'ULONG64'
ERROR: c:\\mingw\\include\\basetsd.h:116: Syntax error at 'DWORD64'
ERROR: c:\\mingw\\include\\basetsd.h:117: Syntax error at 'UINT64'
ERROR: c:\\mingw\\include\\winnt.h:2477: Syntax error at 'ULONGLONG'
ERROR: c:\\mingw\\include\\winnt.h:2711: Syntax error at 'ULONGLONG'
ERROR: c:\\mingw\\include\\winnt.h:2839: Syntax error at 'ULONGLONG'
ERROR: c:\\mingw\\include\\winnt.h:2845: Syntax error at '}'
ERROR: c:\\mingw\\include\\winnt.h:3047: Syntax error at 'ULONGLONG'
ERROR: c:\\mingw\\include\\winnt.h:3062: Syntax error at 'SizeOfStackReserve'
ERROR: c:\\mingw\\include\\winnt.h:3069: Syntax error at '}'
ERROR: c:\\mingw\\include\\winnt.h:3162: Syntax error at 'IMAGE_OPTIONAL_HEADER64'
ERROR: c:\\mingw\\include\\winnt.h:3324: Syntax error at 'ULONGLONG'
ERROR: c:\\mingw\\include\\winnt.h:3372: Syntax error at 'ULONGLONG'
ERROR: c:\\mingw\\include\\winnt.h:3378: Syntax error at '}'
ERROR: c:\\mingw\\include\\winnt.h:3456: Syntax error at 'ULONGLONG'
ERROR: c:\\mingw\\include\\winnt.h:3465: Syntax error at 'EditList'
ERROR: c:\\mingw\\include\\winnt.h:3467: Syntax error at '}'
ERROR: c:\\mingw\\include\\winnt.h:3524: Syntax error at 'ULONGLONG'
ERROR: c:\\mingw\\include\\winnt.h:3630: Syntax error at 'ULONGLONG'
ERROR: c:\\mingw\\include\\winnt.h:3752: Syntax error at 'IO_COUNTERS'
ERROR: c:\\mingw\\include\\winnt.h:3757: Syntax error at 'IO_COUNTERS'
ERROR: c:\\mingw\\include\\winnt.h:3762: Syntax error at '}'
ERROR: c:\\mingw\\include\\winnt.h:4106: Syntax error at 'VerSetConditionMask'
ERROR: c:\\mingw\\include\\winnt.h:4221: Syntax error at 'aux'
ERROR: c:\\mingw\\include\\winnt.h:4221: Syntax error at 'modify'
ERROR: c:\\mingw\\include\\winnt.h:4227: Syntax error at 'aux'
ERROR: c:\\mingw\\include\\winnt.h:4227: Syntax error at 'modify'
ERROR: c:\\mingw\\include\\winnt.h:4234: Syntax error at 'aux'
ERROR: c:\\mingw\\include\\winnt.h:4234: Syntax error at 'modify'
ERROR: c:\\mingw\\include\\winbase.h:1554: Syntax error at 'DECLSPEC_NORETURN'
ERROR: c:\\mingw\\include\\winbase.h:1702: Syntax error at 'PULARGE_INTEGER'
ERROR: c:\\mingw\\include\\winbase.h:1704: Syntax error at 'PULARGE_INTEGER'
ERROR: c:\\mingw\\include\\winbase.h:2259: Syntax error at 'FILE_SEGMENT_ELEMENT'
ERROR: c:\\mingw\\include\\winbase.h:2446: Syntax error at 'DWORDLONG'
ERROR: c:\\mingw\\include\\winbase.h:2448: Syntax error at 'DWORDLONG'
ERROR: c:\\mingw\\include\\winbase.h:2479: Syntax error at 'FILE_SEGMENT_ELEMENT'
ERROR: c:\\mingw\\include\\winbase.h:2546: Syntax error at 'DWORDLONG'
ERROR: c:\\mingw\\include\\winbase.h:2652: Syntax error at 'PIO_COUNTERS'
ERROR: c:\\mingw\\include\\rpcdcep.h:89: Syntax error at 'DECLARE_STDCALL_P'
ERROR: c:\\mingw\\include\\rpcdcep.h:89: Syntax error at ';'
ERROR: c:\\mingw\\include\\wtypes.h:317: Syntax error at 'ULONGLONG'
ERROR: c:\\mingw\\include\\winspool.h:460: Syntax error at 'DWORDLONG'
ERROR: c:\\mingw\\include\\winspool.h:465: Syntax error at '}'
ERROR: c:\\mingw\\include\\winspool.h:479: Syntax error at 'DWORDLONG'
ERROR: c:\\mingw\\include\\winspool.h:484: Syntax error at '}'
ERROR: c:\\mingw\\include\\winspool.h:917: Syntax error at 'DRIVER_INFO_6'
ERROR: c:\\mingw\\include\\winsock.h:592: Syntax error at 'inet_ntoa'
ERROR: c:\\mingw\\include\\winsock.h:604: Syntax error at 'gethostbyaddr'
ERROR: c:\\mingw\\include\\winsock.h:605: Syntax error at 'gethostbyname'
ERROR: c:\\mingw\\include\\winsock.h:606: Syntax error at 'getservbyport'
ERROR: c:\\mingw\\include\\winsock.h:606: Syntax error at ')'
ERROR: c:\\mingw\\include\\winsock.h:607: Syntax error at 'getservbyname'
ERROR: c:\\mingw\\include\\winsock.h:607: Syntax error at ')'
ERROR: c:\\mingw\\include\\winsock.h:608: Syntax error at 'getprotobynumber'
ERROR: c:\\mingw\\include\\winsock.h:609: Syntax error at 'getprotobyname'
ERROR: <built-in>:230: Syntax error at '\n'
ERROR: <built-in>:231: Syntax error at '\n'
ERROR: <built-in>:232: Syntax error at '\n'
ERROR: <built-in>:233: Syntax error at '\n'
ERROR: <built-in>:234: Syntax error at '\n'
ERROR: <built-in>:235: Syntax error at '\n'
ERROR: <built-in>:236: Syntax error at '\n'
ERROR: <built-in>:237: Syntax error at '\n'
ERROR: c:\\mingw\\include\\basetyps.h:47: Syntax error at '\n'
ERROR: c:\\mingw\\include\\basetyps.h:73: Syntax error at '\n'
ERROR: c:\\mingw\\include\\basetyps.h:91: Syntax error at '\n'
INFO: Status: Processing description list.
WARNING: Could not parse macro "#define __declspec(x) __attribute__ ( ( x ) )"
WARNING: Macro "FPDF_EXPORT" depends on an unknown identifier "dllimport". Macro "FPDF_EXPORT" will not be output

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

2 participants