build.rs static link bug on windows
devdoer3 opened this issue · comments
devdoer commented
#[cfg(feature = "cpp")]
#[cfg(not(target_os = "macos"))]
fn main() {
cc::Build::new()
.cpp(true)
.flag("-std=c++11")
**.static_crt(true)**
.file("src/esaxx.cpp")
.include("src")
.compile("esaxx");
}
static_crt(true) should be static_crt(false)?
Nicolas Patry commented
This is required for windows builds: #6
devdoer commented
This is required for windows builds: #6
My platform is windows, by removing static_link_crt , it worked, otherwise , it reports link error.
As below:
#[cfg(feature = "cpp")]
#[cfg(not(target_os = "macos"))]
fn main() {
cc::Build::new()
.cpp(true)
.flag("-std=c++11")
.static_crt(false)
.file("src/esaxx.cpp")
.include("src")
.compile("esaxx");
}
#[cfg(feature = "cpp")]
#[cfg(target_os = "macos")]
fn main() {
cc::Build::new()
.cpp(true)
.flag("-std=c++11")
.flag("-stdlib=libc++")
.static_crt(true)
.file("src/esaxx.cpp")
.include("src")
.compile("esaxx");
}
#[cfg(not(feature = "cpp"))]
fn main() {}