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

Build problem: cannot find -lc++ #772

Closed
0-wiz-0 opened this issue Feb 14, 2025 · 12 comments · Fixed by #777
Closed

Build problem: cannot find -lc++ #772

0-wiz-0 opened this issue Feb 14, 2025 · 12 comments · Fixed by #777
Labels
bug Something isn't working upstream

Comments

@0-wiz-0
Copy link

0-wiz-0 commented Feb 14, 2025

Version

0.5.1, but also ecc05cd

Description

I've tried packaging this for pkgsrc. My test system is a NetBSD-10.99.12/x86_64.
The build seems to mostly work fine, but at the end, linking fails with:

   Compiling unrar v0.5.7
error: linking with `cc` failed: exit status: 1
  |
  = note: LC_ALL="C" PATH="/usr/pkg/lib/rustlib/x86_64-unknown-netbsd/bin:/usr/pkg/lib/rustlib/x86_64-unknown-netbsd/bin:/usr/pkg/lib/rustlib/x86_64-unknown-netbsd/bin:/scratch/wip/ouch/work/.cwrapper/bin:/scratch/wip/ouch/work/.buildlink/bin:/scratch/wip/ouch/work/.gcc/bin:/scratch/wip/ouch/work/.tools/bin:/usr/pkg/bin:/usr/bin:/bin:/usr/pkg/bin:/usr/local/bin:/sbin:/usr/sbin:/usr/local/bin:/usr/pkg_bulk/bin:/usr/pkg/bin:/usr/pkg/bin" VSLANG="1033" "cc" "-Wl,-R/usr/pkg/lib/libatomic" "-Wl,-L/usr/pkg/lib/libatomic" "-m64" "/tmp/rustcekknHa/symbols.o" "/scratch/wip/ouch/work/ouch-ecc05cdd60dc7e180ddf10a2e6a3c6bcea475321/target/release/deps/ouch-4e3663c301fdeb2c.ouch.fa12934dc8acb9d4-cgu.0.rcgu.o" "-Wl,--as-needed" "-Wl,-Bstatic" "/tmp/rustcekknHa/libzstd_sys-b2bc71eaec4db6a4.rlib" "/tmp/rustcekknHa/liblzma_sys-a6b6aeb0ad42aecb.rlib" "/tmp/rustcekknHa/libbzip2_sys-277a4
e3ea078da0a.rlib" "/tmp/rustcekknHa/liblibbzip3_sys-e696356b96914af3.rlib" "/tmp/rustcekknHa/libunrar_sys-60c2102fcfe3e739.rlib" "/usr/pkg/lib/rustlib/x86_64-unknown-netbsd/lib/libcompiler_builtins-4f6bad7a53f64524.rlib" "-Wl,-Bdynamic" "-lz" "-lc++" "-lpthread" "-lutil" "-lrt" "-lutil" "-lexecinfo" "-lexecinfo" "-lpthread" "-lrt" "-lgcc_s" "-lc" "-lm" "-lrt" "-lpthread" "-lutil" "-lrt" "-lutil" "-lexecinfo" "-Wl,--eh-frame-hdr" "-Wl,-z,noexecstack" "-L" "/scratch/wip/ouch/work/ouch-ecc05cdd60dc7e180ddf10a2e6a3c6bcea475321/target/release/build/bzip2-sys-a836338c410cbcb7/out/lib" "-L" "/scratch/wip/ouch/work/ouch-ecc05cdd60dc7e180ddf10a2e6a3c6bcea475321/target/release/build/libbzip3-sys-e2c868e6f835058a/out" "-L" "/scratch/wip/ouch/work/ouch-ecc05cdd60dc7e180ddf10a2e6a3c6bcea475321/target/release/build/unrar_sys-009dd15ab9827324/out" "-L" "/scratch/wip/ouch/work/ouch-ecc05cdd60dc7e180ddf10a2e6a3c6bcea475321/target/release/build/lzma-sys-1e8898c0ff919b25/out" "-L" "/scratch/wip/ouch/work/ouch-ecc05cdd60dc7e180ddf10a2e6a3c6bcea475321/target/release/build/zstd-sys-e9ae2d61d7708ce0/out" "-o" "/scratch/wip/ouch/work/ouch-ecc05cdd60dc7e180ddf10a2e6a3c6bcea475321/target/release/deps/ouch-4e3663c301fdeb2c" "-Wl,--gc-sections" "-pie" "-Wl,-z,relro,-z,now" "-Wl,-O1" "-Wl,--strip-all"
  = note: ld: cannot find -lc++: No such file or directory

My system does not provide a libc++ library, but it has a libstdc++ one. I think that is quite common, so I wonder if there's some code that checks for this and just doesn't trigger correctly on my system.

Current Behavior

Linking fails, see above.

Expected Behavior

Linking succeeds.

Additional Information

No response

@0-wiz-0 0-wiz-0 added the bug Something isn't working label Feb 14, 2025
@0323pin
Copy link

0323pin commented Feb 14, 2025

@0-wiz-0 can you try adding USE_TOOLS+= pkg-config? It usually fixes this sort of issues.

@0-wiz-0
Copy link
Author

0-wiz-0 commented Feb 14, 2025

Thanks for the suggestion, but no, this doesn't help.

@0323pin
Copy link

0323pin commented Feb 14, 2025

Worth a try 😞

@marcospb19
Copy link
Member

marcospb19 commented Feb 14, 2025

Could it be unrar?

https://github.com/muja/unrar.rs/blob/85e2ed8aefdc127d3ad1f2b0475e2f5b3ad28ee3/unrar_sys/build.rs#L68

To validate, can you run cargo new, copy this code to src/main.rs, add unrar = "=0.5.7" to the Cargo.toml and see if you can cargo build it? (or cargo run)

If the build script for unrar-sys is messing this up, then it should fail there too.

@0-wiz-0
Copy link
Author

0-wiz-0 commented Feb 14, 2025

Yes, that test with unrar fails too. So I guess I'll have to report it there. Thanks.

@marcospb19
Copy link
Member

marcospb19 commented Feb 15, 2025

Nice, @0-wiz-0 even if that's fixed, would you need me to make a new assets release, or are you packaging "from source"?

EDIT: based on the name, I assume pkgsrc builds from source.
EDIT2: thanks for packaging Ouch!!!

@0-wiz-0
Copy link
Author

0-wiz-0 commented Feb 15, 2025

pkgsrc builds from source, but we like to package releases, so a new release would be nice.
Thanks!

@0-wiz-0
Copy link
Author

0-wiz-0 commented Feb 19, 2025

I submitted a patch upstream, and it was merged, and there are new releases of unrar and unrar_sys.
Can you please run cargo update (making sure that both unrar and unrar_sys are bumped to 0.5.8 in Cargo.toml)?
I tested this locally and this fixes the build.

The tests are another matter though, I'll attach the log - quite a bit of failures.

test.txt

@marcospb19
Copy link
Member

Tests are OK locally for me.

Similar to the previous case, now this is looking like a problem with the .gz lib.

Can you try the examples at https://github.com/sstadick/gzp/blob/main/examples

Or this example here:

use std::{fs::File, io::Write};

use gzp::{deflate::Gzip, par::compress::ParCompress};

fn main() {
    let path = "/tmp/data.gz";

    let mut xorshift: u32 = 1;
    // 1MB of "random" data
    let buf: Vec<u8> = (0..1024 * 1024)
        .map(|_| {
            // Marsaglia, "Xorshift RNGs"
            xorshift ^= xorshift << 13;
            xorshift ^= xorshift >> 17;
            xorshift ^= xorshift << 5;
            xorshift as u8
        })
        .collect();
    let file = File::create(path).unwrap();
    let mut writer = ParCompress::<Gzip>::builder().from_writer(file);
    writer.write_all(&buf).unwrap();
    writer.flush().unwrap();

    println!("ok, file is at {path}");
}

With this Cargo.toml:

[package]
name = "rust-test"
version = "0.1.0"
edition = "2024"

[dependencies]
gzp = "=0.11.3"

(You can change the path I picked for the file before running.)

If I got this right, it should fail again.

@0-wiz-0
Copy link
Author

0-wiz-0 commented Feb 28, 2025

There was a problem in core_affinity_rs, which is now fixed, and both it and gzp have a new release.
After running cargo update, cargo test now succeeds on NetBSD:

     Running unittests src/main.rs (target/debug/deps/ouch-ec0fb214bde1d757)

running 7 tests
test extension::tests::test_extensions_from_path ... ok
test utils::formatting::tests::test_pretty_bytes_formatting ... ok
test extension::tests::builds_suggestion_correctly ... ok
test extension::tests::test_parse_of_format_flag ... ok
test extension::tests::test_separate_known_extensions_from_name ... ok
test cli::args::tests::test_clap_cli_err ... ok
test cli::args::tests::test_clap_cli_ok ... ok

test result: ok. 7 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.00s

     Running tests/integration.rs (target/debug/deps/integration-e2837d6af8b3bcd5)

running 8 tests
test utils::src_is_not_tests - should panic ... ok
test utils::src_is_src ... ok
test unpack_rar_stdin ... ok
test unpack_rar ... ok
test multiple_files ... ok
test single_file ... ok
test single_empty_file ... ok
test single_file_stdin ... ok

test result: ok. 8 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 13.40s

     Running tests/mime.rs (target/debug/deps/mime-c44e026b5d9ddacd)

running 3 tests
test utils::src_is_src ... ok
test utils::src_is_not_tests - should panic ... ok
test sanity_check_through_mime ... ok

test result: ok. 3 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.08s

     Running tests/ui.rs (target/debug/deps/ui-a5bcb1910a115655)

running 10 tests
test utils::src_is_src ... ok
test utils::src_is_not_tests - should panic ... ok
test ui_test_ok_decompress ... ok
test ui_test_err_compress_missing_extension ... ok
test ui_test_usage_help_flag ... ok
test ui_test_err_missing_files ... ok
test ui_test_ok_format_flag ... ok
test ui_test_err_format_flag ... ok
test ui_test_err_decompress_missing_extension ... ok
test ui_test_ok_compress ... ok

test result: ok. 10 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.06s

     Running tests/utils.rs (target/debug/deps/utils-5d0c70b35fafbf5e)

running 2 tests
test src_is_src ... ok
test src_is_not_tests - should panic ... ok

test result: ok. 2 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.00s

Please run cargo update! Thank you.

@marcospb19 marcospb19 linked a pull request Mar 1, 2025 that will close this issue
@marcospb19
Copy link
Member

Thanks for taking this journey, did the cargo update.

@0-wiz-0
Copy link
Author

0-wiz-0 commented Mar 1, 2025

Thank you, and thanks for the help!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working upstream
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants