Closed
Description
In the demo, I have Rust calls my C function which links to an external library.
With rustc 1.17.0-nightly (8c4f2c64c 2017-03-22)
and before, it builds and runs successfully. With rustc 1.18.0-nightly (666e7148d 2017-04-08)
and later, I get undefined reference
s. I get these Rust's from the official distribution (though without rustup). My system is Arch Linux up-to-date.
Running `rustc --crate-name linkissue src/main.rs --crate-type bin --emit=dep-info,link -C debuginfo=2 -C metadata=9db7c238d92ce6c3 -C extra-filename=-9db7c238d92ce6c3 --out-dir /home/lilydjwg/temp/linkissue/target/debug/deps -L dependency=/home/lilydjwg/temp/linkissue/target/debug/deps -L native=/usr/lib -L native=/home/lilydjwg/temp/linkissue/target/debug/build/linkissue-ab7e3c957d2eb908/out -l lua -l m -l static=c-sys`
error: linking with `cc` failed: exit code: 1
|
= note: "cc" "-Wl,--as-needed" "-Wl,-z,noexecstack" "-m64" "-L" "/usr/lib64/rustlib/x86_64-unknown-linux-gnu/lib" "/home/lilydjwg/temp/linkissue/target/debug/deps/linkissue-9db7c238d92ce6c3.0.o" "-o" "/home/lilydjwg/temp/linkissue/target/debug/deps/linkissue-9db7c238d92ce6c3" "-Wl,--gc-sections" "-pie" "-nodefaultlibs" "-L" "/home/lilydjwg/temp/linkissue/target/debug/deps" "-L" "/usr/lib" "-L" "/home/lilydjwg/temp/linkissue/target/debug/build/linkissue-ab7e3c957d2eb908/out" "-L" "/usr/lib64/rustlib/x86_64-unknown-linux-gnu/lib" "-l" "lua" "-l" "m" "-Wl,-Bstatic" "-Wl,--whole-archive" "-l" "c-sys" "-Wl,--no-whole-archive" "/usr/lib/rustlib/x86_64-unknown-linux-gnu/lib/libstd-f4594d3e53dcb114.rlib" "/usr/lib/rustlib/x86_64-unknown-linux-gnu/lib/librand-1efbcfd8938372b6.rlib" "/usr/lib/rustlib/x86_64-unknown-linux-gnu/lib/libcollections-532a3dbf317eff86.rlib" "/usr/lib/rustlib/x86_64-unknown-linux-gnu/lib/libstd_unicode-cfbd6648f7db2ee5.rlib" "/usr/lib/rustlib/x86_64-unknown-linux-gnu/lib/libpanic_unwind-a0157c0ca919c364.rlib" "/usr/lib/rustlib/x86_64-unknown-linux-gnu/lib/libunwind-488b4ab4bd53a138.rlib" "/usr/lib/rustlib/x86_64-unknown-linux-gnu/lib/liballoc-ca07b617414dd0fa.rlib" "/usr/lib/rustlib/x86_64-unknown-linux-gnu/lib/liballoc_jemalloc-492d8ea7fa3384ff.rlib" "/usr/lib/rustlib/x86_64-unknown-linux-gnu/lib/liblibc-88c194c15fdb6521.rlib" "/usr/lib/rustlib/x86_64-unknown-linux-gnu/lib/libcore-687e6a964d22cbb4.rlib" "/usr/lib/rustlib/x86_64-unknown-linux-gnu/lib/libcompiler_builtins-987729be881d4d32.rlib" "-Wl,-Bdynamic" "-l" "dl" "-l" "rt" "-l" "pthread" "-l" "gcc_s" "-l" "pthread" "-l" "c" "-l" "m" "-l" "rt" "-l" "util"
= note: /home/lilydjwg/temp/linkissue/target/debug/build/linkissue-ab7e3c957d2eb908/out/libc-sys.a(c.o): In function `call_c':
/home/lilydjwg/temp/linkissue/src/c.c:8: undefined reference to `luaL_newstate'
/home/lilydjwg/temp/linkissue/src/c.c:9: undefined reference to `luaL_openlibs'
/home/lilydjwg/temp/linkissue/src/c.c:10: undefined reference to `luaL_loadstring'
/home/lilydjwg/temp/linkissue/src/c.c:10: undefined reference to `lua_pcallk'
collect2: error: ld returned 1 exit status
error: aborting due to previous error
I've diff'ed cargo run -vv
, all other parts are the same, only the above error report appears with newer versions.
PS: you can replace lua53
in build.rs
with whatever version you have in your system. It shouldn't matter.
PPS: this error occurs in Ubuntu 14.04 too.