Narsil / esaxx-rs

Bindings to copy of SentencePiece esaxx library (fast suffix array and frequent substrings).

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

build.rs static link bug on windows

devdoer3 opened this issue · comments

#[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)?

This is required for windows builds: #6

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() {}