-
Notifications
You must be signed in to change notification settings - Fork 496
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
shared_flag and static_flag don't work #594
Comments
Is the issue intended to be fixed? |
how can I build dylib with cc crate? |
Same Problem. |
Same Problem too |
你好 ,您发给我的邮件我已经收到。
|
Any solution to this one? |
This issue is due to cc always run ar, changing it should be possible. cc @ChrisDenton @thomcc What's your thoughts on this? |
Here's a workaround for this: let out_dir = Path::new(std::env::var("OUT_DIR").unwrap());
let builder = cc::Build::new().file("src/foo.c");
let objects = builder.compile_intermediates();
builder
.get_compiler()
.to_command()
.args(["-shared", "-o"])
.arg(out_dir.join("libfoo.so"))
.args(&objects)
.status()
.unwrap(); |
Just following up here, this is doubly true on MSVC where the -shared flag actually triggers an error |
I've received your message, and will respond as soon as possible.
|
Heads up: This is being discussed in #1444. Personally, I'm against having this feature in I'd be more in favour of someone creating a separate crate like |
Well yeah, having a separate crate might be more reasonable, given that we already expose enough API for them to use cc to do compiler detection/etc Like we can expose some APIs useful for link-rs/dynlib-rs |
The
-shared
and-static
flags are linkage flags, and don't do anything when passed alongside-c
.Taking the example from shared_flag:
What that does is:
The first command is strictly equivalent to
cc $OTHER_FLAGS -o foo.o -c src/foo.c
. So in practice, it makes no difference whether shared_flag was passed or not, andcompile("libfoo.so")
would make you think you'd end up with a dynamic library, but you don't.The text was updated successfully, but these errors were encountered: