The error is certainly nasty and shouldn't happen like that, but yes, there was something wrong with what you did: the module columbus isn't public. Change `mod columbus` to `pub mod columbus` and it'll work.
On Wed, Aug 14, 2013 at 1:50 PM, Joshua Warner <[email protected]>wrote: > Hi, > > I'm seeing some strange behavior when modifying the "hello world" crates > example in the 0.7 tutorial ( > http://static.rust-lang.org/doc/0.7/tutorial.html#modules-and-crates). > It works fine as is, but when I modify it such that the "explore" function > is inside a nested module, it compiles fine but I get undefined reference > errors during the linking process. > > Is this intended behavior? Is this a bug, or am I doing something wrong? > > Thanks, > Joshua > > ---------------------- > > I'm using rust 0.7, on ubuntu 12.04 (64-bit). What follows is a set of > commands to reproduce the problem: > > ---------------------- Bash: ---------------------- > cat > hello.rs <<EOF > extern mod world; > > fn main() { > println("hello " + world::columbus::explore()); > } > EOF > > cat > world.rs <<EOF > #[ link(name = "world", > vers = "0.1")]; > > #[ crate_type = "lib" ]; > > mod columbus { > pub fn explore() -> &str { "world" } > } > EOF > > rustc world.rs > rustc -o hello -L . hello.rs > > ---------------------- Output compiling hello.rs: ---------------------- > error: linking with `cc` failed with code 1 > note: cc arguments: -L/usr/local/lib/rustc/x86_64-unknown-linux-gnu/lib > -m64 -o hello hello.o -L/usr/local/lib/rustc/x86_64-unknown-linux-gnu/lib > -lstd-6c65cf4b443341b1-0.7 -L. -lworld-15fb3a718ea23983-0.1 -lrustrt -lrt > -lpthread -L. -lrt -ldl -lm -lmorestack -lrustrt > -Wl,-rpath,$ORIGIN/../../../../../usr/local/lib/rustc/x86_64-unknown-linux-gnu/lib > -Wl,-rpath,$ORIGIN/. > -Wl,-rpath,/usr/local/lib/rustc/x86_64-unknown-linux-gnu/lib > -Wl,-rpath,/tmp/test/. > note: hello.o: In function `main::_f3d4197390d6bb2a::_0$x2e0': > hello.rc:(.text+0x54): undefined reference to > `columbus::explore::_3de4895354bdc485::_0$x2e1' > collect2: ld returned 1 exit status > > error: aborting due to previous error > > _______________________________________________ > Rust-dev mailing list > [email protected] > https://mail.mozilla.org/listinfo/rust-dev > >
_______________________________________________ Rust-dev mailing list [email protected] https://mail.mozilla.org/listinfo/rust-dev
