Closed
Description
Program:
extern crate test_1_lib;
fn main() {
// Uncomment this function call to make linking succeed:
// test_1_lib::some_function();
vec![0u8; test_1_lib::SOME_VALUE.some_member];
}
test_1_lib:
pub struct SomeType {
pub some_member: usize,
}
pub static SOME_VALUE: SomeType = SomeType {
some_member: 1,
};
pub fn some_function() { }
The full test case is available at https://github.com/briansmith/rust-bug-2.
To reproduce:
git clone https://github.com/briansmith/rust-bug-2
cd bin
cargo build
Linking fails with:
test_1_bin.0.o : error LNK2019: unresolved external symbol __imp__ZN10SOME_VALUE20hc1593d2370c9bbcfiaaE referenced in fu
nction _ZN4main20hf3c40dca13f06b85faaE
C:\<REDACTED>\test_1_bin.exe : fatal error LNK1120: 1 unresolved externals
Notice that the program only uses a static variable, and no functions, from the
library crate. If you uncomment the function call in
bin/src/test_1_bin.rs then linking succeeds.
Reproduced with (on x86_64-pc-windows-msvc):
Metadata
Metadata
Assignees
Labels
No labels