Skip to content
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

libduckdb-sys build failed #413

Open
pty819 opened this issue Dec 11, 2024 · 5 comments
Open

libduckdb-sys build failed #413

pty819 opened this issue Dec 11, 2024 · 5 comments

Comments

@pty819
Copy link

pty819 commented Dec 11, 2024

Hello! I'm using duckdb in my rust code, but I cannt add it into my cargo
After using cargo add duckdb --features bundled and cargo run, this happenes
Is there someone facing such issues the same as me? How to solve it?
Waiting for the aid....

error: failed to run custom build command for libduckdb-sys v1.1.1

Caused by:
process didn't exit successfully: D:\rsuploader\target\debug\build\libduckdb-sys-e241cf1d72830267\build-script-build (exit code: 1)
--- stderr

error occurred in cc-rs: Command "C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\VC\Tools\MSVC\14.42.34433\bin\HostX64\x64\cl.exe" "-nologo" "-MD" "-Z7" "-Brepro" "-I" "duckdb" "-I" "D:\rsuploader\target\debug\build\libduckdb-sys-6c8c2a903944fbe3\out/duckdb/third_party/mbedtls/library" "-I" "D:\rsuploader\target\debug\build\libduckdb-sys-6c8c2a903944fbe3\out/duckdb/third_party/brotli/common" "-I" "D:\rsuploader\target\debug\build\libduckdb-sys-6c8c2a903944fbe3\out/duckdb/third_party/brotli/dec" "-I" "D:\rsuploader\target\debug\build\libduckdb-sys-6c8c2a903944fbe3\out/duckdb/third_party/utf8proc" "-I" "D:\rsuploader\target\debug\build\libduckdb-sys-6c8c2a903944fbe3\out/duckdb/third_party/miniz" "-I" "D:\rsuploader\target\debug\build\libduckdb-sys-6c8c2a903944fbe3\out/duckdb/third_party/brotli/enc" "-I" "D:\rsuploader\target\debug\build\libduckdb-sys-6c8c2a903944fbe3\out/duckdb/src/include" "-I" "D:\rsuploader\target\debug\build\libduckdb-sys-6c8c2a903944fbe3\out/duckdb/third_party/re2" "-I" "D:\rsuploader\target\debug\build\libduckdb-sys-6c8c2a903944fbe3\out/duckdb/third_party/libpg_query/include" "-I" "D:\rsuploader\target\debug\build\libduckdb-sys-6c8c2a903944fbe3\out/duckdb/third_party/fast_float" "-I" "D:\rsuploader\target\debug\build\libduckdb-sys-6c8c2a903944fbe3\out/duckdb/third_party/tdigest" "-I" "D:\rsuploader\target\debug\build\libduckdb-sys-6c8c2a903944fbe3\out/duckdb/third_party/lz4" "-I" "D:\rsuploader\target\debug\build\libduckdb-sys-6c8c2a903944fbe3\out/duckdb/third_party/pcg" "-I" "D:\rsuploader\target\debug\build\libduckdb-sys-6c8c2a903944fbe3\out/duckdb/third_party/brotli/include" "-I" "D:\rsuploader\target\debug\build\libduckdb-sys-6c8c2a903944fbe3\out/duckdb/third_party/skiplist" "-I" "D:\rsuploader\target\debug\build\libduckdb-sys-6c8c2a903944fbe3\out/duckdb/third_party/mbedtls" "-I" "D:\rsuploader\target\debug\build\libduckdb-sys-6c8c2a903944fbe3\out/duckdb/third_party/mbedtls/include" "-I" "D:\rsuploader\target\debug\build\libduckdb-sys-6c8c2a903944fbe3\out/duckdb/third_party/hyperloglog" "-I" "D:\rsuploader\target\debug\build\libduckdb-sys-6c8c2a903944fbe3\out/duckdb/third_party/jaro_winkler" "-I" "D:\rsuploader\target\debug\build\libduckdb-sys-6c8c2a903944fbe3\out/duckdb/third_party/httplib" "-I" "D:\rsuploader\target\debug\build\libduckdb-sys-6c8c2a903944fbe3\out/duckdb/third_party/fastpforlib" "-I" "D:\rsuploader\target\debug\build\libduckdb-sys-6c8c2a903944fbe3\out/duckdb/third_party/fsst" "-I" "D:\rsuploader\target\debug\build\libduckdb-sys-6c8c2a903944fbe3\out/duckdb/third_party/concurrentqueue" "-I" "D:\rsuploader\target\debug\build\libduckdb-sys-6c8c2a903944fbe3\out/duckdb/third_party/fmt/include" "-I" "D:\rsuploader\target\debug\build\libduckdb-sys-6c8c2a903944fbe3\out/duckdb/third_party/libpg_query" "-I" "D:\rsuploader\target\debug\build\libduckdb-sys-6c8c2a903944fbe3\out/duckdb/third_party/yyjson/include" "-I" "D:\rsuploader\target\debug\build\libduckdb-sys-6c8c2a903944fbe3\out/duckdb/third_party/utf8proc/include" "-I" "D:\rsuploader\target\debug\build\libduckdb-sys-6c8c2a903944fbe3\out/duckdb/third_party/jaro_winkler/details" "/bigobj" "-DDUCKDB_EXTENSION_AUTOINSTALL_DEFAULT=1" "-DDUCKDB_EXTENSION_AUTOLOAD_DEFAULT=1" "-DDUCKDB_BUILD_LIBRARY" "-FoD:\rsuploader\target\debug\build\libduckdb-sys-6c8c2a903944fbe3\out\9f89209d66126409-ub_src_execution.o" "-c" "D:\rsuploader\target\debug\build\libduckdb-sys-6c8c2a903944fbe3\out/duckdb/ub_src_execution.cpp" with args cl.exe did not execute successfully (status code exit code: 2).

@suhli
Copy link

suhli commented Dec 12, 2024

same here

@suhli
Copy link

suhli commented Dec 12, 2024

duckdb/ub_src_execution.cpp

It seems there is an incorrect path separator when building the project on Windows. After modifying build.rs in libduckdb-sys, the build works but still encounters missing dependencies.

Code Changes in build.rs:144

cfg.include(lib_name);
for dir in include_dirs
    .into_iter()
    .map(|file| format!("{out_dir}/{file}"))
{
    let p = std::path::absolute(&dir).unwrap();
    let include_dir = p.to_str().unwrap();
    cfg.include(&include_dir);
}

for f in cpp_files
    .into_iter()
    .map(|file| format!("{out_dir}/{file}"))
{
    let p = std::path::absolute(&f).unwrap();
    let cpp_file = p.to_str().unwrap();
    cfg.file(&cpp_file);
}

These changes seem to resolve the path separator issue, but the build still fails due to missing dependencies.

error: failed to run custom build command for `libduckdb-sys v1.1.1`

Caused by:
  process didn't exit successfully: `C:\Users\shuhangli\repos\duck\target\debug\build\libduckdb-sys-20bb858660463ed6\build-script-build` (exit code: 1)
  --- stderr

When running the build command, the following error is encountered:

C:\Users\shuhangli\repos\duck\target\debug\build\libduckdb-sys-a92432ca358d0c6c\out\duckdb\third_party\skiplist\SkipList.cpp(9): fatal error C1083: 无法打开包括文件: “cstdlib”: No such file or directory

@frectonz @ankrgyl

@pty819
Copy link
Author

pty819 commented Dec 17, 2024

duckdb/ub_src_execution.cpp

It seems there is an incorrect path separator when building the project on Windows. After modifying build.rs in libduckdb-sys, the build works but still encounters missing dependencies.

Code Changes in build.rs:144

cfg.include(lib_name);
for dir in include_dirs
    .into_iter()
    .map(|file| format!("{out_dir}/{file}"))
{
    let p = std::path::absolute(&dir).unwrap();
    let include_dir = p.to_str().unwrap();
    cfg.include(&include_dir);
}

for f in cpp_files
    .into_iter()
    .map(|file| format!("{out_dir}/{file}"))
{
    let p = std::path::absolute(&f).unwrap();
    let cpp_file = p.to_str().unwrap();
    cfg.file(&cpp_file);
}

These changes seem to resolve the path separator issue, but the build still fails due to missing dependencies.

error: failed to run custom build command for `libduckdb-sys v1.1.1`

Caused by:
  process didn't exit successfully: `C:\Users\shuhangli\repos\duck\target\debug\build\libduckdb-sys-20bb858660463ed6\build-script-build` (exit code: 1)
  --- stderr

When running the build command, the following error is encountered:

C:\Users\shuhangli\repos\duck\target\debug\build\libduckdb-sys-a92432ca358d0c6c\out\duckdb\third_party\skiplist\SkipList.cpp(9): fatal error C1083: 无法打开包括文件: “cstdlib”: No such file or directory

@frectonz @ankrgyl

Yep, seems there is a huge mistake among the libduckdb-sys... I tried to set Environment path to static link the libduckdb, but I cant fix that also. So I turned to use rusqlite....

@suhli
Copy link

suhli commented Dec 17, 2024

duckdb/ub_src_execution.cpp

It seems there is an incorrect path separator when building the project on Windows. After modifying build.rs in libduckdb-sys, the build works but still encounters missing dependencies.

Code Changes in build.rs:144

cfg.include(lib_name);
for dir in include_dirs
    .into_iter()
    .map(|file| format!("{out_dir}/{file}"))
{
    let p = std::path::absolute(&dir).unwrap();
    let include_dir = p.to_str().unwrap();
    cfg.include(&include_dir);
}

for f in cpp_files
    .into_iter()
    .map(|file| format!("{out_dir}/{file}"))
{
    let p = std::path::absolute(&f).unwrap();
    let cpp_file = p.to_str().unwrap();
    cfg.file(&cpp_file);
}

These changes seem to resolve the path separator issue, but the build still fails due to missing dependencies.

error: failed to run custom build command for `libduckdb-sys v1.1.1`

Caused by:
  process didn't exit successfully: `C:\Users\shuhangli\repos\duck\target\debug\build\libduckdb-sys-20bb858660463ed6\build-script-build` (exit code: 1)
  --- stderr

When running the build command, the following error is encountered:

C:\Users\shuhangli\repos\duck\target\debug\build\libduckdb-sys-a92432ca358d0c6c\out\duckdb\third_party\skiplist\SkipList.cpp(9): fatal error C1083: 无法打开包括文件: “cstdlib”: No such file or directory

@frectonz @ankrgyl

Yep, seems there is a huge mistake among the libduckdb-sys... I tried to set Environment path to static link the libduckdb, but I cant fix that also. So I turned to use rusqlite....

I was able to successfully build and run the project by setting the following environment variables in project/.cargo/config.toml:

  • DUCKDB_INCLUDE_DIR
  • DUCKDB_LIB_DIR
  • DUCKDB_STATIC=1

I used the stable-x86_64-pc-windows-msvc toolchain along with the Git Bash environment.

However, when running tests or debugging, a build.rs script is still required to copy the lib/dll files to the deps directory.

build.rs:

fn main() {
    let duck_db_dir = std::env::var("DUCKDB_INCLUDE_DIR").unwrap();
    let profile = std::env::var("PROFILE").unwrap();
    let (os, extension) = match std::env::consts::OS {
        "windows" => ("windows", "dll"),
        "linux" => ("linux", "so"),
        _ => {
            eprintln!("Unsupported OS: {}", std::env::consts::OS);
            std::process::exit(1);
        }
    };
    let file_path = std::path::Path::new(&duck_db_dir).join(std::format!("duckdb.{}", extension));
    let target_dir = std::fs::canonicalize(
        std::path::Path::new("target")
            .join(profile),
    ).expect("file not found");
    println!(
        "cargo:warning=will copy {} to {}",
        file_path.to_str().unwrap(),
        target_dir.to_str().unwrap()
    );
    std::fs::copy(
        file_path,
        target_dir.join(std::format!("duckdb.{}", extension)),
    )
    .expect("copy duckdb failed");
}

@pty819
Copy link
Author

pty819 commented Dec 19, 2024

duckdb/ub_src_execution.cpp

It seems there is an incorrect path separator when building the project on Windows. After modifying build.rs in libduckdb-sys, the build works but still encounters missing dependencies.

Code Changes in build.rs:144

cfg.include(lib_name);
for dir in include_dirs
    .into_iter()
    .map(|file| format!("{out_dir}/{file}"))
{
    let p = std::path::absolute(&dir).unwrap();
    let include_dir = p.to_str().unwrap();
    cfg.include(&include_dir);
}

for f in cpp_files
    .into_iter()
    .map(|file| format!("{out_dir}/{file}"))
{
    let p = std::path::absolute(&f).unwrap();
    let cpp_file = p.to_str().unwrap();
    cfg.file(&cpp_file);
}

These changes seem to resolve the path separator issue, but the build still fails due to missing dependencies.

error: failed to run custom build command for `libduckdb-sys v1.1.1`

Caused by:
  process didn't exit successfully: `C:\Users\shuhangli\repos\duck\target\debug\build\libduckdb-sys-20bb858660463ed6\build-script-build` (exit code: 1)
  --- stderr

When running the build command, the following error is encountered:

C:\Users\shuhangli\repos\duck\target\debug\build\libduckdb-sys-a92432ca358d0c6c\out\duckdb\third_party\skiplist\SkipList.cpp(9): fatal error C1083: 无法打开包括文件: “cstdlib”: No such file or directory

@frectonz @ankrgyl

Yep, seems there is a huge mistake among the libduckdb-sys... I tried to set Environment path to static link the libduckdb, but I cant fix that also. So I turned to use rusqlite....

I was able to successfully build and run the project by setting the following environment variables in project/.cargo/config.toml:

  • DUCKDB_INCLUDE_DIR
  • DUCKDB_LIB_DIR
  • DUCKDB_STATIC=1

I used the stable-x86_64-pc-windows-msvc toolchain along with the Git Bash environment.

However, when running tests or debugging, a build.rs script is still required to copy the lib/dll files to the deps directory.

build.rs:

fn main() {
    let duck_db_dir = std::env::var("DUCKDB_INCLUDE_DIR").unwrap();
    let profile = std::env::var("PROFILE").unwrap();
    let (os, extension) = match std::env::consts::OS {
        "windows" => ("windows", "dll"),
        "linux" => ("linux", "so"),
        _ => {
            eprintln!("Unsupported OS: {}", std::env::consts::OS);
            std::process::exit(1);
        }
    };
    let file_path = std::path::Path::new(&duck_db_dir).join(std::format!("duckdb.{}", extension));
    let target_dir = std::fs::canonicalize(
        std::path::Path::new("target")
            .join(profile),
    ).expect("file not found");
    println!(
        "cargo:warning=will copy {} to {}",
        file_path.to_str().unwrap(),
        target_dir.to_str().unwrap()
    );
    std::fs::copy(
        file_path,
        target_dir.join(std::format!("duckdb.{}", extension)),
    )
    .expect("copy duckdb failed");
}

I will have a try, thank you!!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants