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

Linker error when building pure rust project #21534

Closed
TyOverby opened this issue Jan 23, 2015 · 8 comments
Closed

Linker error when building pure rust project #21534

TyOverby opened this issue Jan 23, 2015 · 8 comments

Comments

@TyOverby
Copy link
Contributor

There is too much code for me to upload, but what is happening is this:

I have a library "Lux". Lux builds just fine when run with cargo build. One of the tests however, uses functionality in Lux, and the compiler crashes with a linker error.

error: linking with `cc` failed: exit code: 1
note: cc '-Wl,--as-needed' '-m64' '-L' '/homes/iws/tyoverby/lib/rustlib/x86_64-unknown-linux-gnu/lib' '-o' '/homes/iws/tyoverby/workspace/Personal/rust/lux/target/examples/spritesheet' '/homes/iws/tyoverby/workspace/Personal/rust/lux/target/examples/spritesheet.o' '-Wl,--whole-archive' '-lmorestack' '-Wl,--no-whole-archive' '-Wl,--gc-sections' '-pie' '-nodefaultlibs' '/homes/iws/tyoverby/workspace/Personal/rust/lux/target/liblux-0044c44cb706a208.rlib' '-L' '/homes/iws/tyoverby/workspace/Personal/rust/lux/target/deps' '-lglium_macros-0d63a9614c44c703' '-L' '/homes/iws/tyoverby/lib/rustlib/x86_64-unknown-linux-gnu/lib' '-lrustc-4e7c5e5c' '-L' '/homes/iws/tyoverby/lib/rustlib/x86_64-unknown-linux-gnu/lib' '-lrustc_back-4e7c5e5c' '-L' '/homes/iws/tyoverby/lib/rustlib/x86_64-unknown-linux-gnu/lib' '-lsyntax-4e7c5e5c' '-L' '/homes/iws/tyoverby/lib/rustlib/x86_64-unknown-linux-gnu/lib' '-lterm-4e7c5e5c' '-L' '/homes/iws/tyoverby/lib/rustlib/x86_64-unknown-linux-gnu/lib' '-lrustc_llvm-4e7c5e5c' '-L' '/homes/iws/tyoverby/lib/rustlib/x86_64-unknown-linux-gnu/lib' '-larena-4e7c5e5c' '-L' '/homes/iws/tyoverby/lib/rustlib/x86_64-unknown-linux-gnu/lib' '-lgetopts-4e7c5e5c' '/homes/iws/tyoverby/workspace/Personal/rust/lux/target/deps/libvecmath-350a77008be8648b.rlib' '-L' '/homes/iws/tyoverby/lib/rustlib/x86_64-unknown-linux-gnu/lib' '-lrbml-4e7c5e5c' '/homes/iws/tyoverby/workspace/Personal/rust/lux/target/deps/libglium-af9a1675d224f665.rlib' '/homes/iws/tyoverby/workspace/Personal/rust/lux/target/deps/libglutin-abe6f4e5d9a1c8bb.rlib' '/homes/iws/tyoverby/workspace/Personal/rust/lux/target/deps/libcgmath-40919635fc2a19d7.rlib' '/homes/iws/tyoverby/workspace/Personal/rust/lux/target/deps/libimage-49298ff37d3495f7.rlib' '/homes/iws/tyoverby/workspace/Personal/rust/lux/target/deps/libnum-5b0bc2450b7c80b1.rlib' '/homes/iws/tyoverby/workspace/Personal/rust/lux/target/deps/libnalgebra-1b2cab07beb57e5d.rlib' '/homes/iws/tyoverby/workspace/Personal/rust/lux/target/deps/librustc-serialize-32ba0ff0c50e3a4d.rlib' '-L' '/homes/iws/tyoverby/lib/rustlib/x86_64-unknown-linux-gnu/lib' '-lflate-4e7c5e5c' '-L' '/homes/iws/tyoverby/lib/rustlib/x86_64-unknown-linux-gnu/lib' '-lfmt_macros-4e7c5e5c' '/homes/iws/tyoverby/workspace/Personal/rust/lux/target/deps/libgl_common-f44d989b8724e1a7.rlib' '-L' '/homes/iws/tyoverby/lib/rustlib/x86_64-unknown-linux-gnu/lib' '-lserialize-4e7c5e5c' '-L' '/homes/iws/tyoverby/lib/rustlib/x86_64-unknown-linux-gnu/lib' '-llog-4e7c5e5c' '-L' '/homes/iws/tyoverby/lib/rustlib/x86_64-unknown-linux-gnu/lib' '-lregex-4e7c5e5c' '/homes/iws/tyoverby/workspace/Personal/rust/lux/target/deps/libtypemap-3efd7ccbb9d24a2a.rlib' '/homes/iws/tyoverby/workspace/Personal/rust/lux/target/deps/libunsafe-any-3f018797a3613438.rlib' '-L' '/homes/iws/tyoverby/lib/rustlib/x86_64-unknown-linux-gnu/lib' '-lgraphviz-4e7c5e5c' '-L' '/homes/iws/tyoverby/lib/rustlib/x86_64-unknown-linux-gnu/lib' '-lstd-4e7c5e5c' '-L' '/homes/iws/tyoverby/workspace/Personal/rust/lux/target' '-L' '/homes/iws/tyoverby/workspace/Personal/rust/lux/target/deps' '-L' '/usr/lib64' '-L' '/usr/lib64' '-L' '/homes/iws/tyoverby/lib/rustlib/x86_64-unknown-linux-gnu/lib' '-L' '/homes/iws/tyoverby/workspace/Personal/rust/lux/.rust/lib/x86_64-unknown-linux-gnu' '-L' '/homes/iws/tyoverby/workspace/Personal/rust/lux/lib/x86_64-unknown-linux-gnu' '-Wl,--whole-archive' '-Wl,-Bstatic' '-Wl,--no-whole-archive' '-Wl,-Bdynamic' '-lpthread' '-lrt' '-ldl' '-lm' '-lGL' '-lX11' '-lXxf86vm' '-lXcursor' '-ldl' '-lpthread' '-lrt' '-lgcc_s' '-lpthread' '-lc' '-lm' '-lcompiler-rt'
note: /homes/iws/tyoverby/workspace/Personal/rust/lux/target/examples/spritesheet.o: In function `spritesheet::main':
/homes/iws/tyoverby/workspace/Personal/rust/lux/examples/spritesheet.rs:20: undefined reference to `sprite::SpriteSheet::get::hb2fae00cafba72c7sMc'
collect2: error: ld returned 1 exit status

error: aborting due to previous error
Could not compile `lux`.
@steveklabnik
Copy link
Member

what does cargo build --verbose say?

@alexcrichton
Copy link
Member

There are some know linkage errors related to privacy, would it be possible for me to peek at the code to reproduce and see what's going on?

@TyOverby
Copy link
Contributor Author

@steveklabnik cargo build is the one that works, so it gives me

bash-4.2$ cargo build --verbose
       Fresh khronos_api v0.0.4
       Fresh pkg-config v0.1.5
       Fresh unsafe-any v0.2.1
       Fresh regex v0.1.10
       Fresh bitflags v0.1.0
       Fresh glium_macros v0.0.1 (https://github.com/tomaka/glium.git#fe9e2b5b)
       Fresh rustc-serialize v0.2.8
       Fresh vecmath v0.0.3 (https://github.com/PistonDevelopers/vecmath#3080ca14)
       Fresh phantom v0.0.3
       Fresh gl_common v0.0.3
       Fresh compile_msg v0.1.3 (https://github.com/huonw/compile_msg#b19da50c)
       Fresh khronos_api v0.0.5
       Fresh log v0.1.9
       Fresh xml-rs v0.1.13
       Fresh nalgebra v0.2.0 (https://github.com/sebcrozet/nalgebra#713589ff)
       Fresh num v0.1.9 (https://github.com/rust-lang/num#51b94c5e)
       Fresh cgmath v0.0.1 (https://github.com/bjz/cgmath-rs#9bb77e6a)
       Fresh typemap v0.0.8 (https://github.com/reem/rust-typemap#3594b654)
       Fresh gl_generator v0.0.12
       Fresh image v0.2.0-alpha.6 (https://github.com/PistonDevelopers/image#52fe4324)
       Fresh libz-sys v0.1.0
       Fresh freetype-sys v0.0.2 (https://github.com/PistonDevelopers/freetype-sys#b0c1eaa3)
       Fresh glutin v0.0.4-pre (https://github.com/tomaka/glutin.git#13be9b25)
       Fresh freetype-rs v0.0.3 (https://github.com/PistonDevelopers/freetype-rs#b3db542d)
       Fresh glium v0.0.2 (https://github.com/tomaka/glium.git#fe9e2b5b)
   Compiling lux v0.0.1 (file:///homes/iws/tyoverby/workspace/Personal/rust/lux)
     Running `rustc src/lib.rs --crate-name lux --crate-type lib -g -C metadata=0044c44cb706a208 -C extra-filename=-0044c44cb706a208 --out-dir /homes/iws/tyoverby/workspace/Personal/rust/lux/target --emit=dep-info,link -L dependency=/homes/iws/tyoverby/workspace/Personal/rust/lux/target -L dependency=/homes/iws/tyoverby/workspace/Personal/rust/lux/target/deps --extern freetype=/homes/iws/tyoverby/workspace/Personal/rust/lux/target/deps/libfreetype-47f57fe79f3e1411.rlib --extern glutin=/homes/iws/tyoverby/workspace/Personal/rust/lux/target/deps/libglutin-abe6f4e5d9a1c8bb.rlib --extern vecmath=/homes/iws/tyoverby/workspace/Personal/rust/lux/target/deps/libvecmath-350a77008be8648b.rlib --extern glium_macros=/homes/iws/tyoverby/workspace/Personal/rust/lux/target/deps/libglium_macros-0d63a9614c44c703.so --extern image=/homes/iws/tyoverby/workspace/Personal/rust/lux/target/deps/libimage-49298ff37d3495f7.rlib --extern glium=/homes/iws/tyoverby/workspace/Personal/rust/lux/target/deps/libglium-af9a1675d224f665.rlib --extern typemap=/homes/iws/tyoverby/workspace/Personal/rust/lux/target/deps/libtypemap-3efd7ccbb9d24a2a.rlib -L native=/usr/lib64 -L native=/usr/lib64`
     Running `rustc src/bin.rs --crate-name lux_demo --crate-type bin -g --out-dir /homes/iws/tyoverby/workspace/Personal/rust/lux/target --emit=dep-info,link -L dependency=/homes/iws/tyoverby/workspace/Personal/rust/lux/target -L dependency=/homes/iws/tyoverby/workspace/Personal/rust/lux/target/deps --extern freetype=/homes/iws/tyoverby/workspace/Personal/rust/lux/target/deps/libfreetype-47f57fe79f3e1411.rlib --extern glutin=/homes/iws/tyoverby/workspace/Personal/rust/lux/target/deps/libglutin-abe6f4e5d9a1c8bb.rlib --extern vecmath=/homes/iws/tyoverby/workspace/Personal/rust/lux/target/deps/libvecmath-350a77008be8648b.rlib --extern glium_macros=/homes/iws/tyoverby/workspace/Personal/rust/lux/target/deps/libglium_macros-0d63a9614c44c703.so --extern image=/homes/iws/tyoverby/workspace/Personal/rust/lux/target/deps/libimage-49298ff37d3495f7.rlib --extern glium=/homes/iws/tyoverby/workspace/Personal/rust/lux/target/deps/libglium-af9a1675d224f665.rlib --extern typemap=/homes/iws/tyoverby/workspace/Personal/rust/lux/target/deps/libtypemap-3efd7ccbb9d24a2a.rlib --extern lux=/homes/iws/tyoverby/workspace/Personal/rust/lux/target/liblux-0044c44cb706a208.rlib -L native=/usr/lib64 -L native=/usr/lib64`
src/bin.rs:29:5: 29:33 warning: unused result which must be used, #[warn(unused_must_use)] on by default
src/bin.rs:29     face.set_pixel_sizes(0, 48);
                  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~

@TyOverby
Copy link
Contributor Author

@alexcrichton: I added you as a collaborator on the repo. The issue lies with examples/spritesheet.rs and src/sprite.rs.

@TyOverby
Copy link
Contributor Author

@alexcrichton:

going off of your hunch that it has to do with visibility, I discovered that I wasn't correctly reexporting the type from the crate. I didn't notice this because I'm used to getting the compiler warning (error?) about using private types in a public API.

@alexcrichton
Copy link
Member

Yeah the bug I'm thinking of is #16734. Thanks for giving me access! I'll investigate when I get a chance and see if I can confirm a dupe of #16734 or get a minimized example.

@alexcrichton
Copy link
Member

Ok, checked it out and did some investigation, and it looks like this is indeed a dupe of #16734, thanks for letting me poke around!

@TyOverby
Copy link
Contributor Author

No prob! Thanks for identifying it!

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

3 participants