Something wrong with no_std when link on windows


#1

i writed a simple program and enabled no_std feature.after compiling,an error appeared.what does it means?

error: linking with link.exe failed: exit code: 1120
|
= note: “C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\bin\amd64\link.exe” “/LIBPATH:C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\lib\amd64” “/LIBPATH:C:\Program Files (x86)\Windows Kits\10\lib\10.0.10586.0\ucrt\x64” “/LIBPATH:C:\Program Files (x86)\Windows Kits\10\lib\10.0.10586.0\um\x64” “/NOLOGO” “/NXCOMPAT” “/LIBPATH:C:\Users\fdfdfdfdf\.rustup\toolchains\nightly-x86_64-pc-windows-msvc\lib\rustlib\x86_64-pc-windows-msvc\lib” “G:\Develop\rust\s1\target\debug\deps\s1-04635d0910fbbee5.0.o” “/OUT:G:\Develop\rust\s1\target\debug\deps\s1-04635d0910fbbee5.exe” “/OPT:REF,NOICF” “/DEBUG” “/LIBPATH:G:\Develop\rust\s1\target\debug\deps” “/LIBPATH:C:\Users\fdfdfdfdf\.rustup\toolchains\nightly-x86_64-pc-windows-msvc\lib\rustlib\x86_64-pc-windows-msvc\lib” “C:\Users\fdfdfdfdf\.rustup\toolchains\nightly-x86_64-pc-windows-msvc\lib\rustlib\x86_64-pc-windows-msvc\lib\libcore-ea9d77e7c23fe65c.rlib”
= note: Non-UTF-8 output: LINK : error LNK2001: \xce\xde\xb7\xa8\xbd\xe2\xce\xf6\xb5\xc4\xcd\xe2\xb2\xbf\xb7\xfb\xba\xc5 mainCRTStartup\r\nlibcore-ea9d77e7c23fe65c.rlib(core-ea9d77e7c23fe65c.0.o) : error LNK2019: \xce\xde\xb7\xa8\xbd\xe2\xce\xf6\xb5\xc4\xcd\xe2\xb2\xbf\xb7\xfb\xba\xc5 memcpy\xa3\xac\xb8\xc3\xb7\xfb\xba\xc5\xd4\xda\xba\xaf\xca\xfd _ZN4core3num7flt2dec8strategy6dragon9mul_pow1017h70c775aef6ec6378E \xd6\xd0\xb1\xbb\xd2\xfd\xd3\xc3\r\nlibcore-ea9d77e7c23fe65c.rlib(core-ea9d77e7c23fe65c.0.o) : error LNK2019: \xce\xde\xb7\xa8\xbd\xe2\xce\xf6\xb5\xc4\xcd\xe2\xb2\xbf\xb7\xfb\xba\xc5 memset\xa3\xac\xb8\xc3\xb7\xfb\xba\xc5\xd4\xda\xba\xaf\xca\xfd _ZN4core3num7flt2dec8strategy6dragon12format_exact17h2e4c0ae194f2e50eE \xd6\xd0\xb1\xbb\xd2\xfd\xd3\xc3\r\nlibcore-ea9d77e7c23fe65c.rlib(core-ea9d77e7c23fe65c.0.o) : error LNK2019: \xce\xde\xb7\xa8\xbd\xe2\xce\xf6\xb5\xc4\xcd\xe2\xb2\xbf\xb7\xfb\xba\xc5 __muloti4\xa3\xac\xb8\xc3\xb7\xfb\xba\xc5\xd4\xda\xba\xaf\xca\xfd _ZN4core3num14from_str_radix17h7239c7a625628776E \xd6\xd0\xb1\xbb\xd2\xfd\xd3\xc3\r\nlibcore-ea9d77e7c23fe65c.rlib(core-ea9d77e7c23fe65c.0.o) : error LNK2019: \xce\xde\xb7\xa8\xbd\xe2\xce\xf6\xb5\xc4\xcd\xe2\xb2\xbf\xb7\xfb\xba\xc5 __udivti3\xa3\xac\xb8\xc3\xb7\xfb\xba\xc5\xd4\xda\xba\xaf\xca\xfd _ZN4core3num14from_str_radix17hcbba40156486c7c8E \xd6\xd0\xb1\xbb\xd2\xfd\xd3\xc3\r\nlibcore-ea9d77e7c23fe65c.rlib(core-ea9d77e7c23fe65c.0.o) : error LNK2019: \xce\xde\xb7\xa8\xbd\xe2\xce\xf6\xb5\xc4\xcd\xe2\xb2\xbf\xb7\xfb\xba\xc5 rust_begin_unwind\xa3\xac\xb8\xc3\xb7\xfb\xba\xc5\xd4\xda\xba\xaf\xca\xfd _ZN4core9panicking9panic_fmt17h48d156f2bd7d9203E \xd6\xd0\xb1\xbb\xd2\xfd\xd3\xc3\r\nlibcore-ea9d77e7c23fe65c.rlib(core-ea9d77e7c23fe65c.0.o) : error LNK2019: \xce\xde\xb7\xa8\xbd\xe2\xce\xf6\xb5\xc4\xcd\xe2\xb2\xbf\xb7\xfb\xba\xc5 memcmp\xa3\xac\xb8\xc3\xb7\xfb\xba\xc5\xd4\xda\xba\xaf\xca\xfd _ZN4core3str7pattern11StrSearcher3new17h4cd5eb27c8c3d1c1E \xd6\xd0\xb1\xbb\xd2\xfd\xd3\xc3\r\nlibcore-ea9d77e7c23fe65c.rlib(core-ea9d77e7c23fe65c.0.o) : error LNK2019: \xce\xde\xb7\xa8\xbd\xe2\xce\xf6\xb5\xc4\xcd\xe2\xb2\xbf\xb7\xfb\xba\xc5 __umodti3\xa3\xac\xb8\xc3\xb7\xfb\xba\xc5\xd4\xda\xba\xaf\xca\xfd ZN4core3fmt3num53$LT$impl$u20$core…fmt…Display$u20$for$u20$i128$GT$3fmt17h19f738b8cd4dc395E \xd6\xd0\xb1\xbb\xd2\xfd\xd3\xc3\r\nG:\Develop\rust\s1\target\debug\deps\s1-04635d0910fbbee5.exe : fatal error LNK1120: 8 \xb8\xf6\xce\xde\xb7\xa8\xbd\xe2\xce\xf6\xb5\xc4\xcd\xe2\xb2\xbf\xc3\xfc\xc1\xee\r\n


#2

If you put three backticks ``` on a line before your error log, and three more on a line after it, it will be displayed as-is and not have the formatter muck it up like this.

Did you do everything required of a #![no_std] project? It looks like you don’t have the language items for panicking, memory operations, or displaying to console. You’ll need to manually provide functions tagged as language items #[start], #[rust_eh_personality], and … one other that I can’t remember offhand. You will also need crate rlibc as a dependency to provide memcmp (which I can see is missing) and other low-level memory operations. I’m not sure offhand why core::fmt::Display isn’t found, but I’m not at all surprised by that.

Why are you writing this as #![no_std]? Unless you’re putting the project in a microcontroller or an OS kernel, there’s not much reason to do this.