MSVC linker error when compiling a simple program

So I run THIS CODE:

use std::fs;
use std::fs::File;
use std::io::{BufRead, BufReader};
use std::prelude::rust_2021::String as String;
use std::{thread, time};



pub fn main() {
    let data = fs::read_to_string("config.set");
    let fsread = data;
    let mut stringset:String;
	let mut stringset = String::new();
    let mut auga:String;
    let mut augb:String;
    let mut setting;
	let mut stringsetaug:String;
	let mut stringsetaug = String::new();
    setting = "A";
	let f = BufReader::new(File::open("main.fs").expect("open failed"));
    for line in f.lines() {
		setting = "A";
        for c in line.expect("lines failed").chars() {
            // main system
			if setting == "A" {
				stringset.push(c);
				if c == ' ' {
					setting = "B";
				}
            }
            if c != ';' {
				if setting != "A" {
					stringsetaug.push(c);
					}
                }
             
			if c == ';' {
				if setting != "A" {
					//processing unit
					stringsetaug.remove(0);
					if stringset == "println" {
						println!("{}", stringsetaug);
					}
					if stringset == "dischange" {
						println!("FLUFFSCRIPT SOFTWARE 2021");
					}
					println!("{}", stringset);
					println!("{}", stringsetaug);
					let mut stringset:String;
					let mut stringset = String::new();
					let mut auga:String;
					let mut augb:String;
					setting = "A";
					let mut stringsetaug:String;
					let mut stringsetaug = String::new();
					let mut stringsetaug = String::new();
					
				}
                }
			}
	}		
	thread::sleep(time::Duration::from_millis(10000000000));		
}
		


And get this:

warning: unused variable: `fsread`
  --> hello.rs:11:9
   |
11 |     let fsread = data;
   |         ^^^^^^ help: if this is intentional, prefix it with an underscore: `_fsread`
   |
   = note: `#[warn(unused_variables)]` on by default

warning: unused variable: `stringset`
  --> hello.rs:12:13
   |
12 |     let mut stringset:String;
   |             ^^^^^^^^^ help: if this is intentional, prefix it with an underscore: `_stringset`

warning: unused variable: `auga`
  --> hello.rs:14:13
   |
14 |     let mut auga:String;
   |             ^^^^ help: if this is intentional, prefix it with an underscore: `_auga`

warning: unused variable: `augb`
  --> hello.rs:15:13
   |
15 |     let mut augb:String;
   |             ^^^^ help: if this is intentional, prefix it with an underscore: `_augb`

warning: unused variable: `stringsetaug`
  --> hello.rs:17:10
   |
17 |     let mut stringsetaug:String;
   |             ^^^^^^^^^^^^ help: if this is intentional, prefix it with an underscore: `_stringsetaug`

warning: value assigned to `setting` is never read
  --> hello.rs:19:5
   |
19 |     setting = "A";
   |     ^^^^^^^
   |
   = note: `#[warn(unused_assignments)]` on by default
   = help: maybe it is overwritten before being read?

warning: unused variable: `stringset`
  --> hello.rs:49:14
   |
49 |                     let mut stringset:String;
   |                             ^^^^^^^^^ help: if this is intentional, prefix it with an underscore: `_stringset`

warning: unused variable: `stringset`
  --> hello.rs:50:14
   |
50 |                     let mut stringset = String::new();
   |                             ^^^^^^^^^ help: if this is intentional, prefix it with an underscore: `_stringset`

warning: unused variable: `auga`
  --> hello.rs:51:14
   |
51 |                     let mut auga:String;
   |                             ^^^^ help: if this is intentional, prefix it with an underscore: `_auga`

warning: unused variable: `augb`
  --> hello.rs:52:14
   |
52 |                     let mut augb:String;
   |                             ^^^^ help: if this is intentional, prefix it with an underscore: `_augb`

warning: unused variable: `stringsetaug`
  --> hello.rs:54:14
   |
54 |                     let mut stringsetaug:String;
   |                             ^^^^^^^^^^^^ help: if this is intentional, prefix it with an underscore: `_stringsetaug`

warning: unused variable: `stringsetaug`
  --> hello.rs:55:14
   |
55 |                     let mut stringsetaug = String::new();
   |                             ^^^^^^^^^^^^ help: if this is intentional, prefix it with an underscore: `_stringsetaug`

warning: unused variable: `stringsetaug`
  --> hello.rs:56:14
   |
56 |                     let mut stringsetaug = String::new();
   |                             ^^^^^^^^^^^^ help: if this is intentional, prefix it with an underscore: `_stringsetaug`

warning: variable does not need to be mutable
  --> hello.rs:50:10
   |
50 |                     let mut stringset = String::new();
   |                         ----^^^^^^^^^
   |                         |
   |                         help: remove this `mut`
   |
   = note: `#[warn(unused_mut)]` on by default

warning: variable does not need to be mutable
  --> hello.rs:55:10
   |
55 |                     let mut stringsetaug = String::new();
   |                         ----^^^^^^^^^^^^
   |                         |
   |                         help: remove this `mut`

warning: variable does not need to be mutable
  --> hello.rs:56:10
   |
56 |                     let mut stringsetaug = String::new();
   |                         ----^^^^^^^^^^^^
   |                         |
   |                         help: remove this `mut`

error: linking with `link.exe` failed: exit code: 1104
  |
  = note: "C:\\Program Files\\Microsoft Visual Studio\\2022\\Preview\\VC\\Tools\\MSVC\\14.30.30401\\bin\\HostX64\\x64\\link.exe" "/NOLOGO" "hello.hello.996e1e6f-cgu.0.rcgu.o" "hello.hello.996e1e6f-cgu.1.rcgu.o" "hello.hello.996e1e6f-cgu.10.rcgu.o" "hello.hello.996e1e6f-cgu.11.rcgu.o" "hello.hello.996e1e6f-cgu.12.rcgu.o" "hello.hello.996e1e6f-cgu.13.rcgu.o" "hello.hello.996e1e6f-cgu.14.rcgu.o" "hello.hello.996e1e6f-cgu.15.rcgu.o" "hello.hello.996e1e6f-cgu.2.rcgu.o" "hello.hello.996e1e6f-cgu.3.rcgu.o" "hello.hello.996e1e6f-cgu.4.rcgu.o" "hello.hello.996e1e6f-cgu.5.rcgu.o" "hello.hello.996e1e6f-cgu.6.rcgu.o" "hello.hello.996e1e6f-cgu.7.rcgu.o" "hello.hello.996e1e6f-cgu.8.rcgu.o" "hello.hello.996e1e6f-cgu.9.rcgu.o" "hello.2qbjdfrzgcayd1in.rcgu.o" "/LIBPATH:C:\\Users\\staff\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib" "C:\\Users\\staff\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib\\libstd-137462619eb7fb6e.rlib" "C:\\Users\\staff\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib\\libpanic_unwind-40325f74f03cd910.rlib" "C:\\Users\\staff\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib\\libstd_detect-d499ddbe6ea217f2.rlib" "C:\\Users\\staff\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib\\librustc_demangle-ac7fd557a0876ac7.rlib" "C:\\Users\\staff\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib\\libhashbrown-e027da3f3243b8cb.rlib" "C:\\Users\\staff\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib\\librustc_std_workspace_alloc-d92ff4ce4e9ba04b.rlib" "C:\\Users\\staff\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib\\libunwind-0fbe2e0a0cce010b.rlib" "C:\\Users\\staff\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib\\libcfg_if-994c4132e0b038fc.rlib" "C:\\Users\\staff\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib\\liblibc-37b7cfcd70f86ebc.rlib" "C:\\Users\\staff\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib\\liballoc-598a66e79671d548.rlib" "C:\\Users\\staff\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib\\librustc_std_workspace_core-b40eca52864f4eec.rlib" "C:\\Users\\staff\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib\\libcore-3200edb0d039ab3a.rlib" "C:\\Users\\staff\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib\\libcompiler_builtins-b0e0bca0e70300a2.rlib" "kernel32.lib" "ws2_32.lib" "advapi32.lib" "userenv.lib" "kernel32.lib" "msvcrt.lib" "/NXCOMPAT" "/LIBPATH:C:\\Users\\staff\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib" "/OUT:hello.exe" "/OPT:REF,NOICF" "/DEBUG" "/NATVIS:C:\\Users\\staff\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\etc\\intrinsic.natvis" "/NATVIS:C:\\Users\\staff\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\etc\\liballoc.natvis" "/NATVIS:C:\\Users\\staff\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\etc\\libcore.natvis" "/NATVIS:C:\\Users\\staff\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\etc\\libstd.natvis"
  = note: LINK : fatal error LNK1104: cannot open file 'hello.exe'

And I get these SUS files: [Moderator note: garbled binaries removed. Please use GitHub, or some other file sharing service, for things like that.]

Full rep containing all sussy files:

Those files are unlinked binary objects produced by rustc, one for each "code generation unit" (CGU). In the normal course of events, Rust then invokes the system linker (here link.exe) to put the object files together into an executable. Posting the contents of those files—not even the full contents, it looks like the non-printable bytes have been replaced with spaces—is not helpful for diagnosing your issue. Instead, could you share what's in your Cargo.toml for this project, assuming you tried to build your program with cargo build or cargo run?

Note: I've also replaced the title of your post. Please use less hyperbolic/more informative titles in the future.

2 Likes

Looks like some permissions issue. Can't your antivirus software intervene somehow?

1 Like

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.