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

Adding native libraries as dependencies #250

Closed
kirans-bp opened this issue Oct 26, 2022 · 5 comments · Fixed by #251
Closed

Adding native libraries as dependencies #250

kirans-bp opened this issue Oct 26, 2022 · 5 comments · Fixed by #251
Assignees
Labels
bug Something isn't working

Comments

@kirans-bp
Copy link

I have a rust project with serde as a dependency. When I tried to use bob to build it, I got the following error

= note: ld: library not found for -liconv
        clang-13: error: linker command failed with exit code 1 (use -v to see invocation)

I tried to add libiconv to the dependencies in bob.yaml but the error remained

dependencies:
  - cargo
  - clang_13
  - libiconv
...

However, I could compile it successfully with nix-shell -p cargo clang_13 libiconv.

How do I add these native libraries so that bob can find them?

@Equanox
Copy link
Member

Equanox commented Oct 26, 2022

Hey Kirans, thx for creating this issue. You're doing it right, the dependencies are defined correctly.

I tried to setup a very basic rust project using cargo 1.60.0 & serde on linux, though i couldn't reproduce the error. Guess my project was too basic to reproduce.

This is the bob.yaml I used.

build:
  build: 
    cmd: |
      cd hello_cargo && cargo run
    rebuild: always

dependencies:
  - cargo

And it worked out well, here is the output.

$:~/rustserde$ bob build 
Running task build with 0 dependencies
Using 16 workers

build	      Finished dev [unoptimized + debuginfo] target(s) in 0.01s
build	       Running `target/debug/hello_cargo`
build	  serialized = {"x":1,"y":2}
build	  deserialized = Point { x: 1, y: 2 }
build	...done

● ● ● ●
Ran 1 tasks in 30.3ms
  build              	✔       	(30.3ms)

You can compare environments directly by adding env to the bob build task. This will show you the used dependencies when looking at the PATH.

Can you give me some more information to reproduce your issue? bob version, your system?

@kirans-bp
Copy link
Author

kirans-bp commented Oct 26, 2022

Hi I'm on a Macbook M1. I'm trying to reproduce this issue step by step with a small project and documenting below

bob.yaml

dependencies:
  - cargo

build:
  build:
    cmd: cargo run
    rebuild: always

Cargo.toml

[package]
name = "bobb"
version = "0.1.0"
edition = "2021"

[dependencies]
eyre = "*"

src/main.rs

fn main() -> eyre::Result<()> {
    println!("Hello, world!");
    Ok(())
}

With the above basic setup, the first error I get is

build             error: linker `cc` not found
build               |
build               = note: No such file or directory (os error 2)
build
build             error: could not compile `eyre` due to previous error
build             warning: build failed, waiting for other jobs to finish...

I add clang_13 and rebuild, which gives me

build                Compiling eyre v0.6.8
build             error: linking with `cc` failed: exit status: 1
build               |
build               = note: "cc" "-arch" "arm64" "/tmp/rustc1IKfS7/symbols.o" "/private/tmp/bobb/target/debug/build/eyre-d51eb41dd982e1e7/build_script_build-d51eb41dd982e1e7.build_script_build.950b1ec5-cgu.0.rcgu.o" "/private/tmp/bobb/target/debug/build/eyre-d51eb41dd982e1e7/build_script_build-d51eb41dd982e1e7.build_script_build.950b1ec5-cgu.1.rcgu.o" "/private/tmp/bobb/target/debug/build/eyre-d51eb41dd982e1e7/build_script_build-d51eb41dd982e1e7.build_script_build.950b1ec5-cgu.10.rcgu.o" "/private/tmp/bobb/target/debug/build/eyre-d51eb41dd982e1e7/build_script_build-d51eb41dd982e1e7.build_script_build.950b1ec5-cgu.11.rcgu.o" "/private/tmp/bobb/target/debug/build/eyre-d51eb41dd982e1e7/build_script_build-d51eb41dd982e1e7.build_script_build.950b1ec5-cgu.12.rcgu.o" "/private/tmp/bobb/target/debug/build/eyre-d51eb41dd982e1e7/build_script_build-d51eb41dd982e1e7.build_script_build.950b1ec5-cgu.13.rcgu.o" "/private/tmp/bobb/target/debug/build/eyre-d51eb41dd982e1e7/build_script_build-d51eb41dd982e1e7.build_script_build.950b1ec5-cgu.14.rcgu.o" "/private/tmp/bobb/target/debug/build/eyre-d51eb41dd982e1e7/build_script_build-d51eb41dd982e1e7.build_script_build.950b1ec5-cgu.15.rcgu.o" "/private/tmp/bobb/target/debug/build/eyre-d51eb41dd982e1e7/build_script_build-d51eb41dd982e1e7.build_script_build.950b1ec5-cgu.2.rcgu.o" "/private/tmp/bobb/target/debug/build/eyre-d51eb41dd982e1e7/build_script_build-d51eb41dd982e1e7.build_script_build.950b1ec5-cgu.3.rcgu.o" "/private/tmp/bobb/target/debug/build/eyre-d51eb41dd982e1e7/build_script_build-d51eb41dd982e1e7.build_script_build.950b1ec5-cgu.4.rcgu.o" "/private/tmp/bobb/target/debug/build/eyre-d51eb41dd982e1e7/build_script_build-d51eb41dd982e1e7.build_script_build.950b1ec5-cgu.5.rcgu.o" "/private/tmp/bobb/target/debug/build/eyre-d51eb41dd982e1e7/build_script_build-d51eb41dd982e1e7.build_script_build.950b1ec5-cgu.6.rcgu.o" "/private/tmp/bobb/target/debug/build/eyre-d51eb41dd982e1e7/build_script_build-d51eb41dd982e1e7.build_script_build.950b1ec5-cgu.7.rcgu.o" "/private/tmp/bobb/target/debug/build/eyre-d51eb41dd982e1e7/build_script_build-d51eb41dd982e1e7.build_script_build.950b1ec5-cgu.8.rcgu.o" "/private/tmp/bobb/target/debug/build/eyre-d51eb41dd982e1e7/build_script_build-d51eb41dd982e1e7.build_script_build.950b1ec5-cgu.9.rcgu.o" "/private/tmp/bobb/target/debug/build/eyre-d51eb41dd982e1e7/build_script_build-d51eb41dd982e1e7.k09is1w0h23ctk1.rcgu.o" "-L" "/private/tmp/bobb/target/debug/deps" "-L" "/nix/store/4cv7zfwcagivr385ww5x4s3scy22infp-rustc-1.64.0/lib/rustlib/aarch64-apple-darwin/lib" "/nix/store/4cv7zfwcagivr385ww5x4s3scy22infp-rustc-1.64.0/lib/rustlib/aarch64-apple-darwin/lib/libstd-08068d401c25d211.rlib" "/nix/store/4cv7zfwcagivr385ww5x4s3scy22infp-rustc-1.64.0/lib/rustlib/aarch64-apple-darwin/lib/libpanic_unwind-84be07e68b9d00f4.rlib" "/nix/store/4cv7zfwcagivr385ww5x4s3scy22infp-rustc-1.64.0/lib/rustlib/aarch64-apple-darwin/lib/libobject-4804c562fc61a807.rlib" "/nix/store/4cv7zfwcagivr385ww5x4s3scy22infp-rustc-1.64.0/lib/rustlib/aarch64-apple-darwin/lib/libmemchr-279301e6a5d99fea.rlib" "/nix/store/4cv7zfwcagivr385ww5x4s3scy22infp-rustc-1.64.0/lib/rustlib/aarch64-apple-darwin/lib/libaddr2line-fbfb344f09805b90.rlib" "/nix/store/4cv7zfwcagivr385ww5x4s3scy22infp-rustc-1.64.0/lib/rustlib/aarch64-apple-darwin/lib/libgimli-616191dd1d974165.rlib" "/nix/store/4cv7zfwcagivr385ww5x4s3scy22infp-rustc-1.64.0/lib/rustlib/aarch64-apple-darwin/lib/librustc_demangle-4687ef078813d96d.rlib" "/nix/store/4cv7zfwcagivr385ww5x4s3scy22infp-rustc-1.64.0/lib/rustlib/aarch64-apple-darwin/lib/libstd_detect-1386b7e41dd1fd86.rlib" "/nix/store/4cv7zfwcagivr385ww5x4s3scy22infp-rustc-1.64.0/lib/rustlib/aarch64-apple-darwin/lib/libhashbrown-26b1aa4af9d5f07a.rlib" "/nix/store/4cv7zfwcagivr385ww5x4s3scy22infp-rustc-1.64.0/lib/rustlib/aarch64-apple-darwin/lib/libminiz_oxide-8a7d5d906c81e365.rlib" "/nix/store/4cv7zfwcagivr385ww5x4s3scy22infp-rustc-1.64.0/lib/rustlib/aarch64-apple-darwin/lib/libadler-327750ded6594992.rlib" "/nix/store/4cv7zfwcagivr385ww5x4s3scy22infp-rustc-1.64.0/lib/rustlib/aarch64-apple-darwin/lib/librustc_std_workspace_alloc-b801be618a24f1bf.rlib" "/nix/store/4cv7zfwcagivr385ww5x4s3scy22infp-rustc-1.64.0/lib/rustlib/aarch64-apple-darwin/lib/libunwind-fa75ed5f72174942.rlib" "/nix/store/4cv7zfwcagivr385ww5x4s3scy22infp-rustc-1.64.0/lib/rustlib/aarch64-apple-darwin/lib/libcfg_if-adf0011e71898575.rlib" "/nix/store/4cv7zfwcagivr385ww5x4s3scy22infp-rustc-1.64.0/lib/rustlib/aarch64-apple-darwin/lib/liblibc-3d5bcaabca1cfe44.rlib" "/nix/store/4cv7zfwcagivr385ww5x4s3scy22infp-rustc-1.64.0/lib/rustlib/aarch64-apple-darwin/lib/liballoc-cd287cf1e41c0ec4.rlib" "/nix/store/4cv7zfwcagivr385ww5x4s3scy22infp-rustc-1.64.0/lib/rustlib/aarch64-apple-darwin/lib/librustc_std_workspace_core-d99e291378cbf0b8.rlib" "/nix/store/4cv7zfwcagivr385ww5x4s3scy22infp-rustc-1.64.0/lib/rustlib/aarch64-apple-darwin/lib/libcore-fcdbad0d5b23b740.rlib" "/nix/store/4cv7zfwcagivr385ww5x4s3scy22infp-rustc-1.64.0/lib/rustlib/aarch64-apple-darwin/lib/libcompiler_builtins-9ba449e7b506e8b4.rlib" "-lSystem" "-lresolv" "-lc" "-lm" "-liconv" "-L" "/nix/store/4cv7zfwcagivr385ww5x4s3scy22infp-rustc-1.64.0/lib/rustlib/aarch64-apple-darwin/lib" "-o" "/private/tmp/bobb/target/debug/build/eyre-d51eb41dd982e1e7/build_script_build-d51eb41dd982e1e7" "-Wl,-dead_strip" "-nodefaultlibs"
build               = note: ld: library not found for -liconv
build                       clang-13: error: linker command failed with exit code 1 (use -v to see invocation)
build
build
build             error: could not compile `eyre` due to previous error

I add libiconv and rebuild. It gives me the same error as above.

I'm wondering if its because I'm on M1?

This is my final bob.yaml

dependencies:
  - cargo
  - clang_13
  - libiconv

build:
  build:
    cmd: cargo run
    rebuild: always
» bob --version
bob version 0.6.2 darwin/arm64

@Equanox Equanox added the bug Something isn't working label Oct 26, 2022
@Equanox
Copy link
Member

Equanox commented Oct 26, 2022

Thx, we could reproduce the issue on another M1. It doesn't appear on Linux. Looks like there is indeed a difference between using nix-shell and bob. We'll try to provide a solution asap.

@Equanox
Copy link
Member

Equanox commented Oct 31, 2022

@kirans-bp the 0.6.3 release should fix your issue. We are now making sure the environment is similar to the one genrated by nix-shell, introduced in #251 . Can you double check if the fix works for you?

@zuzuleinen zuzuleinen self-assigned this Oct 31, 2022
@kirans-bp
Copy link
Author

Thanks for the quick fix @Equanox. It works now

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

Successfully merging a pull request may close this issue.

3 participants