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

Using a public module that uses a private module in main.rs causes linking errors #23614

Closed
fables-tales opened this issue Mar 22, 2015 · 2 comments
Labels
I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️

Comments

@fables-tales
Copy link
Contributor

Copied from: https://stackoverflow.com/questions/29186299/compilation-linking-error-undefined-symbols-for-architecture-x86-64

I have no idea what I'm doing, this is my first serious attempt to do anything with rust.

I'm writing a project that this: line https://github.com/samphippen/rexchange/blob/master/src/lib.rs#L1 in it's lib.rs. When I typed cargo build I got the following output:

   $ cargo build --verbose
       Fresh log v0.2.5
       Fresh rustc-serialize v0.3.6
       Fresh libc v0.1.3
       Fresh rand v0.1.4
       Fresh uuid v0.1.11
   Compiling rexchange v0.0.1 (file:///Users/sam/dev/rexchange)
     Running `rustc src/main.rs --crate-name rexchange --crate-type bin -g --out-dir /Users/sam/dev/rexchange/target/debug --emit=dep-info,link -L dependency=/Users/sam/dev/rexchange/target/debug -L dependency=/Users/sam/dev/rexchange/target/debug/deps --extern uuid=/Users/sam/dev/rexchange/target/debug/deps/libuuid-f80da2be6e37bdc9.rlib --extern rexchange=/Users/sam/dev/rexchange/target/debug/librexchange-436e10ddf2e26a6f.rlib`
error: linking with `cc` failed: exit code: 1
note: "cc" "-m64" "-L" "/usr/local/lib/rustlib/x86_64-apple-darwin/lib" "-o" "/Users/sam/dev/rexchange/target/debug/rexchange" "/Users/sam/dev/rexchange/target/debug/rexchange.o" "-Wl,-force_load,/usr/local/lib/rustlib/x86_64-apple-darwin/lib/libmorestack.a" "-Wl,-dead_strip" "-nodefaultlibs" "/Users/sam/dev/rexchange/target/debug/librexchange-436e10ddf2e26a6f.rlib" "/Users/sam/dev/rexchange/target/debug/deps/libuuid-f80da2be6e37bdc9.rlib" "/Users/sam/dev/rexchange/target/debug/deps/librustc-serialize-6bb45c0d7c639d54.rlib" "/Users/sam/dev/rexchange/target/debug/deps/librand-6dfe5258ada5ebf2.rlib" "/Users/sam/dev/rexchange/target/debug/deps/liblibc-2a692f33a70517c8.rlib" "/usr/local/lib/rustlib/x86_64-apple-darwin/lib/libstd-4e7c5e5c.rlib" "/usr/local/lib/rustlib/x86_64-apple-darwin/lib/libcollections-4e7c5e5c.rlib" "/usr/local/lib/rustlib/x86_64-apple-darwin/lib/libunicode-4e7c5e5c.rlib" "/usr/local/lib/rustlib/x86_64-apple-darwin/lib/librand-4e7c5e5c.rlib" "/usr/local/lib/rustlib/x86_64-apple-darwin/lib/liballoc-4e7c5e5c.rlib" "/usr/local/lib/rustlib/x86_64-apple-darwin/lib/liblibc-4e7c5e5c.rlib" "/usr/local/lib/rustlib/x86_64-apple-darwin/lib/libcore-4e7c5e5c.rlib" "-L" "/Users/sam/dev/rexchange/target/debug" "-L" "/Users/sam/dev/rexchange/target/debug/deps" "-L" "/usr/local/lib/rustlib/x86_64-apple-darwin/lib" "-L" "/Users/sam/dev/rexchange/.rust/lib/x86_64-apple-darwin" "-L" "/Users/sam/dev/rexchange/lib/x86_64-apple-darwin" "-lc" "-lm" "-lSystem" "-lpthread" "-lc" "-lm" "-lcompiler-rt"
note: ld: warning: directory not found for option '-L/Users/sam/dev/rexchange/.rust/lib/x86_64-apple-darwin'
ld: warning: directory not found for option '-L/Users/sam/dev/rexchange/lib/x86_64-apple-darwin'
Undefined symbols for architecture x86_64:
  "orders::BidOrder::get_account_id::hbe8193f627eb0daf4ba", referenced from:
      main::h6e33cd0005718795haa in rexchange.o
  "orders::BidOrder::get_currency_price::hac0a15cbc8d29001Gba", referenced from:
      main::h6e33cd0005718795haa in rexchange.o
  "orders::BidOrder::get_commodity_amount::hce97000d2a1749beSba", referenced from:
      main::h6e33cd0005718795haa in rexchange.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

error: aborting due to previous error
Could not compile `rexchange`.

Caused by:
  Process didn't exit successfully: `rustc src/main.rs --crate-name rexchange --crate-type bin -g --out-dir /Users/sam/dev/rexchange/target/debug --emit=dep-info,link -L dependency=/Users/sam/dev/rexchange/target/debug -L dependency=/Users/sam/dev/rexchange/target/debug/deps --extern uuid=/Users/sam/dev/rexchange/target/debug/deps/libuuid-f80da2be6e37bdc9.rlib --extern rexchange=/Users/sam/dev/rexchange/target/debug/librexchange-4

I wasn't expecting this at all, my main.rs doesn't reference those symbols exactly: https://github.com/samphippen/rexchange/blob/master/src/main.rs and also I'd expect a rust error and not a linker level error from clang (if this is an error).

My Rust compiler version is:

$ rustc --version
rustc 1.0.0-nightly (3e4be02b8 2015-03-13) (built 2015-03-13)

My Cargo version is:

$ cargo --version
cargo 0.0.1-pre-nightly (66849de 2015-03-10) (built 2015-03-11)

marking the orders module as public fixed the issue.

@steveklabnik steveklabnik added the I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ label Mar 22, 2015
@steveklabnik
Copy link
Member

not exactly an ICE but close enough

@alexcrichton
Copy link
Member

I believe this is a dupe of #16734, so closing in favor of that, but thanks for the report!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️
Projects
None yet
Development

No branches or pull requests

3 participants