Linker can't link functions from advapi
Bastiaan Veelo
Bastiaan at Veelo.net
Mon Apr 1 15:33:46 UTC 2019
On Monday, 1 April 2019 at 10:07:58 UTC, Deen O'Connor wrote:
> So i got this problem when i tried to compile my project in VS
> 17 with VisualD plugin.
>
> It compiled just fine, i got no errors from DMD, but both
> optlink and vs linker tell me that i have 3 unknown functions -
> OpenProcessToken, LookupPrivilegeValue and
> AdjustTokenPrivileges.
>
> I tried converting advapi32.dll to .lib, this did not solve the
> problem, because with the necessary .lib file set in project
> settings i get a message telling me that my advapi32.lib is
> corrupt.
>
> Idk what to do, and i don't want to re-write everything with
> another language.
I would advise against using optlink, make sure your object file
format is COFF. I can recommend setting up your project for
dub[1]. All I had to do is add this to dub.json:
"libs": [
"Gdi32",
"Comdlg32",
"Winspool",
"Ws2_32",
"wntab32x",
"User32"
],
and compile with `dub build -a=x86_mscoff` for 32bit or `dub
build -a=x86_64` for 64bit. It just works. Granted I also have
this in dub.json
"lflags-x86_mscoff": ["/NODEFAULTLIB:LIBC.lib"]
but I believe that is necessary because of some other libs that
we link with.
[1] https://dub.pm/getting_started
Bastiaan.
More information about the Digitalmars-d
mailing list