-
-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
linkSystemLibrary should not change from static to dynamic linking based on presence of DLL file (or calls to linkLibC()) #9053
Comments
I created this smaller project because I'm having trouble getting my larger project to statically link to .lib files (while cross compiling for Windows). Unfortunately, the workaround of moving the .dll file out of the path did not work for my larger project. After looking more closely, I noticed that my larger project build.zig file includes a call to After adding that call to the sample project build.zig exe step, I can no longer get a valid static build under any circumstance. I've tried:
Now I'm a bit stumped, I was under the impression that zig-cache and zig-out were the only places where state was being held across compilation attempts. Any tips would be enormously appreciated! |
Thanks for the report. This behavior definitely seems fishy so I'd be happy to look into this as part of the 0.8.x release cycle. |
I appreciate that. Out of curiosity, I've tried deleting the cache directories in the project, are there global caches hiding somewhere else that I could try clearing out? Thanks! |
This wiki page shows where all the cache directories are located. |
You can also run |
I did some more spelunking today on this and bumped into the following:
a) Ubuntu Workstation All three environments consistently yield the missing DLL failure. FWIW, I opened the .exe in vim and set hex mode with I don't know what I'm looking at, but it looks like something is inserting a reference to libsoundio.dll in the exe file. Just trying to be helpful, please let me know anyone else is (or isn't) able to reproduce this issue. |
so is static linking just not supported atm? |
First, thanks so much for all your incredible work! This language and working environment are exactly what I've been hoping to find for many, many years.
I'm trying to build an executable for Windows and I'd like to statically link to a .lib file.
I could be wrong, but it looks like the build system will automatically switch from a static link to a dynamic link if it discovers a
.dll
file in the link path.Here's a git project that reproduces the issue.
I'm running with the following:
Contents of README copied below:
zig build -Dtarget=x86_64-windows-gnu && wine64 dist/main.exe
mv libsoundio.dll vendor/libsoundio/ zig build -Dtarget=x86_64-windows-gnu && wine64 dist/main.exe
Will output somethine like:
Move the dll out of the path and it works again.
mv vendor/libsoundio/libsoundio.dll ./ zig build -Dtarget=x86_64-windows-gnu && wine64 dist/main.exe info: All your codebase are belong to us. soundio successfully created context
The text was updated successfully, but these errors were encountered: