Jextract WinUser.h

60 Views Asked by At

I am trying to use Jextract of project panama jdk22-ea

When I run jextract WinUser.h

Then I get the following error:

ERROR: C:\Program Files (x86)\Windows Kits\10\Include\10.0.19041.0\um\winnt.h:173:2: error: "No Target Architecture"

How can I use Jextract to get all functions from User32.dll?

1

There are 1 best solutions below

0
DuncG On

It is easier to use jextract with your own header that sets up suitable target architecture definitions. Try User32.h which simply contains:

#include <shlobj_core.h>

Then run jextract to determine all the symbols from your chosen header file as ALL.sym:

jextract -luser32 -t mypackage --output generated.src User32.h --dump-includes ALL.sym

This gives 50,000+ linesof symbols - far too big to use if you compiled the extracted code. Instead, filter just to the definitions you plan to use by adding --include-xyz ABC parameter per symbol. It is easier to save the included symbols into a separate file such as User32.sym:

--include-function EnumWindows
--include-constant FALSE
--include-constant MAX_PATH 
--include-constant TRUE 

Then run jextract with just the subset of symbols you need adding --include-xyz ABC or including the edited contents of @User32.sym:

jextract -luser32 -t mypackage --output generated.src User32.h @User32.sym

It may take a few iterations with copying lines from ALL.sym to User32.sym to get the right subset of dependencies.