fn link_dylib_internal(
    files: Vec<PathBuf>,
    lib: &Vec<String>,
    libpath: &Vec<String>,
    out: PathBuf
) -> PathBuf {
    let mut object_files: Vec<PathBuf> = vec![];

    // compile each single source file
    for file in files {
        let mut cc = Command::new(get_c_compiler());

        // output object file
        cc.arg("-c");
        // position independent code
        cc.arg("-fPIC");

        let mut out = file.clone();
        out.set_extension("o");

        cc.arg(file.as_os_str());
        cc.arg("-o");
        cc.arg(out.as_os_str());

        object_files.push(out);
        exec_cmd(cc);
    }

    // link object files into a dynamic library
    let mut cc = Command::new(get_c_compiler());

    // external libs
    for path in libpath.iter() {
        cc.arg(format!("-L{}", path));
    }
    for l in lib.iter() {
        cc.arg(format!("-l{}", l));
    }

    // options:
    // shared library
    cc.arg("-shared");
    // position independent code
    cc.arg("-fPIC");
    // allow undefined symbol
    cc.arg("-Wl");
    cc.arg("-undefined");
    // allow dynamic lookup symbols
    cc.arg("dynamic_lookup");

    // all object files
    for obj in object_files {
        cc.arg(obj.as_os_str());
    }

    // output
    cc.arg("-o");
    cc.arg(out.as_os_str());

    exec_cmd(cc);

    out
}
/// invokes the C compiler to link code into a dynamic library
invokes the C compiler to link code into a dynamic library
invokes the C compiler to link code into a dynamic library
fn link_dylib_internal(
    files: Vec<PathBuf>,
    lib: &Vec<String>,
    libpath: &Vec<String>,
    out: PathBuf
) -> PathBuf {
    let mut object_files: Vec<PathBuf> = vec![];
    // compile each single source file
    for file in files {
        let mut cc = Command::new(get_c_compiler());
        // output object file
        cc.arg("-c");
        // position independent code
        cc.arg("-fPIC");
        let mut out = file.clone();
        out.set_extension("o");
        cc.arg(file.as_os_str());
        cc.arg("-o");
        cc.arg(out.as_os_str());
        object_files.push(out);
        exec_cmd(cc);
    }
    // link object files into a dynamic library
    let mut cc = Command::new(get_c_compiler());
    // external libs
    for path in libpath.iter() {
        cc.arg(format!("-L{}", path));
    }
    for l in lib.iter() {
        cc.arg(format!("-l{}", l));
    }
    // options:
    // shared library
    cc.arg("-shared");
    // position independent code
    cc.arg("-fPIC");
    // allow undefined symbol
    cc.arg("-Wl");
    cc.arg("-undefined");
    // allow dynamic lookup symbols
    cc.arg("dynamic_lookup");
    // all object files
    for obj in object_files {
        cc.arg(obj.as_os_str());
    }
    // output
    cc.arg("-o");
    cc.arg(out.as_os_str());
    exec_cmd(cc);
    out
}
fn link_dylib_internal ( files : Vec < PathBuf > , lib : & Vec < String > , libpath : & Vec < String > , out : PathBuf ) -> PathBuf { let mut object_files : Vec < PathBuf > = vec ! [ ] ; // compile each single source file for file in files { let mut cc = Command :: new ( get_c_compiler ( ) ) ; // output object file cc . arg ( " " ) ; // position independent code cc . arg ( " " ) ; let mut out = file . clone ( ) ; out . set_extension ( " " ) ; cc . arg ( file . as_os_str ( ) ) ; cc . arg ( " " ) ; cc . arg ( out . as_os_str ( ) ) ; object_files . push ( out ) ; exec_cmd ( cc ) ; } // link object files into a dynamic library let mut cc = Command :: new ( get_c_compiler ( ) ) ; // external libs for path in libpath . iter ( ) { cc . arg ( format ! ( " " path ) ) ; } for l in lib . iter ( ) { cc . arg ( format ! ( " " l ) ) ; } // options: // shared library cc . arg ( " " ) ; // position independent code cc . arg ( " " ) ; // allow undefined symbol cc . arg ( " " ) ; cc . arg ( " " ) ; // allow dynamic lookup symbols cc . arg ( " " ) ; // all object files for obj in object_files { cc . arg ( obj . as_os_str ( ) ) ; } // output cc . arg ( " " ) ; cc . arg ( out . as_os_str ( ) ) ; exec_cmd ( cc ) ; out }
invokes the C compiler to link code into a dynamic library
invokes the C compiler to link code into a dynamic library
files
Vec<PathBuf>
lib
&Vec<String>
libpath
&Vec<String>
out
PathBuf
files
Vec<PathBuf>
lib
&Vec<String>
libpath
&Vec<String>
out
PathBuf