-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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
Static linking against C Lib with C++ symbols failed to link with unresolved symbols #22244
Comments
Are you building the static library with Zig? |
I've tried with gcc and clang under arch Linux |
Your static library is probably built against libstdc++. Zig uses libc++. Mixing the two is not going to work. |
So I managed to get my example to work with libc++ after a lot of wrestling of cmake and compilers (good luck if you need to use gcc). This is all "okay" if you have complete access to the libraries in question you are trying to static link with zig but I have static libraries that are closed source and linked against libstdc++. Is going down the route having zig link against |
If you can get Zig to link libstdc++, I don't see anything technically wrong with that. |
It wasn't easy so I haven't tried it yet, it can't find the path with a simple |
Zig Version
0.13.0
Steps to Reproduce and Observed Behavior
I can't seem to figure out how to link static libraries in zig when the static library includes C++ symbols (which should be unused).
exe.addObjectFile()
andexe.linkSystemLibrary()
exhibit the same behavior.repository to fully reproduce this issue:
https://github.com/ic3man5/zig_static_lib
default project from zig init plus the following additions:
build.zig
main.zig
C source files:
mylib.h
mylib.cpp
symbols inside the static library:
when building against this header and static lib the following errors happen:
Expected Behavior
Expect zig to be able to link against the static lib without unresolved symbols
The text was updated successfully, but these errors were encountered: