#Error while building static-linked binary

1 messages · Page 1 of 1 (latest)

untold rock
#

I try to build static linked exe, but getting error:

PS C:\Zig\linkage> zig build-exe main.zig -L "libs" -l "zigdll" -O ReleaseSmall -static        
error: unable to create compilation: UnableToStaticLink

How can i fix that?
Thank you in advance!

untold rock
#

it's fixing if delete all .dll files from libs folder, but program can't be executed without zigdll.dll file.

translation:

The programm can't start because zigdll.dll is missing from your computer. Try reinstalling the program to fix the problem.
storm dome
#

extern "zigdll" will make you depend on zigdll.dll at runtime

untold rock
storm dome
#

remove the string

#

extern fn...

#

also if you're statically linking against zig you might as well just use a single compilation unit

#

easier and better

storm dome
untold rock
# storm dome `extern fn...`

Removing extern fn... really helped.
Is there way to "embed" dll file into zig binary? Or i can only do it with embeding dll file bytes into [_]u8 array?

I want my .dll file automatically be load when i start .exe file, like it does C++ . Is it possible?
I want my file to be standalone and can work without dll in the same directory.

#

I try to connect MinHook library and it's have precompiled binaries, such as .lib and .dll files:

storm dome
#

to make the library part of your exe

untold rock
#

And i don't know why

storm dome
#

you can't statically link a .dll

#

.dlls are dynamic linking only

untold rock
#

So, the only one variant is save .dll file bytes to array and then create dll file from runtime?

storm dome
#

If you want to do that you have to manually call LoadLibrary

#

Or find a static build of your library and link against that instead of a .dll