프로그래밍

[rustc] cargo run 시 error: linking with `x86_64-w64-mingw32-gcc` failed: exit code: 1

Hithero 2021. 12. 9. 00:31

에러

$ cargo run
   Compiling guessing_game v0.1.0 (C:\Users\Hyun\OneDrive - skku.edu\study_log\210912~ 알고리즘\doRust\guessing_game)   
error: linking with `x86_64-w64-mingw32-gcc` failed: exit code: 1
  |
  = note: "x86_64-w64-mingw32-gcc" "-fno-use-linker-plugin" "-Wl,--dynamicbase" "-Wl,--disable-auto-image-base" "-m64" "-Wl,--high-entropy-va" "C:\\Users\\Hyun\\scoop\\apps\\rust\\1.57.0\\lib\\rustlib\\x86_64-pc-windows-gnu\\lib\\rsbegin.o" "C:\\Users\\Hyun\\OneDrive - skku.edu\\study_log\\210912~  알고리즘\\doRust\\guessing_game\\target\\debug\\deps\\guessing_game-76d47656c615a8bd.10qd4t3vl5dggyii.rcgu.o" "C:\\Users\\Hyun\\OneDrive - skku.edu\\study_log\\210912~ 알고리즘\\doRust\\guessing_game\\target\\debug\\deps\\guessing_game-76d47656c615a8bd.16zw9wst24178ud4.rcgu.o" "C:\\Users\\Hyun\\OneDrive - skku.edu\\study_log\\210912~ 알고리즘\\doRust\\guessing_game\\target\\debug\\deps\\guessing_game-76d47656c615a8bd.1eoc6tyi8jkohxah.rcgu.o" "C:\\Users\\Hyun\\OneDrive - skku.edu\\study_log\\210912~ 알고리즘\\doRust\\guessing_game\\target\\debug\\deps\\guessing_game-76d47656c615a8bd.1hplge1zf5eguyyr.rcgu.o" "C:\\Users\\Hyun\\OneDrive - skku.edu\\study_log\\210912~ 알고리즘\\doRust\\guessing_game\\target\\debug\\deps\\guessing_game-76d47656c615a8bd.1ivijbprik886hmn.rcgu.o" "C:\\Users\\Hyun\\OneDrive - skku.edu\\study_log\\210912~ 알고리즘\\doRust\\guessing_game\\target\\debug\\deps\\guessing_game-76d47656c615a8bd.1xye7ppbvqcvmrv6.rcgu.o" "C:\\Users\\Hyun\\OneDrive - skku.edu\\study_log\\210912~ 알고리즘\\doRust\\guessing_game\\target\\debug\\deps\\guessing_game-76d47656c615a8bd.2gpcp77jxcamqu5p.rcgu.o" "C:\\Users\\Hyun\\OneDrive - skku.edu\\study_log\\210912~ 알고리즘\\doRust\\guessing_game\\target\\debug\\deps\\guessing_game-76d47656c615a8bd.2hvehzida7va9ohi.rcgu.o" "C:\\Users\\Hyun\\OneDrive - skku.edu\\study_log\\210912~ 알고리즘\\doRust\\guessing_game\\target\\debug\\deps\\guessing_game-76d47656c615a8bd.2ifonpkpv77sm38.rcgu.o" "C:\\Users\\Hyun\\OneDrive - skku.edu\\study_log\\210912~ 알고리즘\\doRust\\guessing_game\\target\\debug\\deps\\guessing_game-76d47656c615a8bd.2mensmmmn4q6gasd.rcgu.o" "C:\\Users\\Hyun\\OneDrive - skku.edu\\study_log\\210912~  알고리즘\\doRust\\guessing_game\\target\\debug\\deps\\guessing_game-76d47656c615a8bd.2mwyj4c1fvk6o21u.rcgu.o" "C:\\Users\\Hyun\\OneDrive - skku.edu\\study_log\\210912~ 알고리즘\\doRust\\guessing_game\\target\\debug\\deps\\guessing_game-76d47656c615a8bd.2t18lbyuvd6isr13.rcgu.o" "C:\\Users\\Hyun\\OneDrive - skku.edu\\study_log\\210912~ 알고리즘\\doRust\\guessing_game\\target\\debug\\deps\\guessing_game-76d47656c615a8bd.2xl1pbs6nciq84uw.rcgu.o" "C:\\Users\\Hyun\\OneDrive - skku.edu\\study_log\\210912~ 알고리즘\\doRust\\guessing_game\\target\\debug\\deps\\guessing_game-76d47656c615a8bd.31ea220sa5g3iqm4.rcgu.o" "C:\\Users\\Hyun\\OneDrive - skku.edu\\study_log\\210912~ 알고리즘\\doRust\\guessing_game\\target\\debug\\deps\\guessing_game-76d47656c615a8bd.34i1dg8plnojdg.rcgu.o" "C:\\Users\\Hyun\\OneDrive - skku.edu\\study_log\\210912~ 알고리즘\\doRust\\guessing_game\\target\\debug\\deps\\guessing_game-76d47656c615a8bd.37shp4gq694hm0sb.rcgu.o" "C:\\Users\\Hyun\\OneDrive - skku.edu\\study_log\\210912~ 알고리즘\\doRust\\guessing_game\\target\\debug\\deps\\guessing_game-76d47656c615a8bd.3h0d9fa57i9q049v.rcgu.o" "C:\\Users\\Hyun\\OneDrive - skku.edu\\study_log\\210912~ 알고리즘\\doRust\\guessing_game\\target\\debug\\deps\\guessing_game-76d47656c615a8bd.3x091ods49juvf29.rcgu.o" "C:\\Users\\Hyun\\OneDrive - skku.edu\\study_log\\210912~ 알고리즘\\doRust\\guessing_game\\target\\debug\\deps\\guessing_game-76d47656c615a8bd.4yolf9p09igensl9.rcgu.o" "C:\\Users\\Hyun\\OneDrive - skku.edu\\study_log\\210912~ 알고리즘\\doRust\\guessing_game\\target\\debug\\deps\\guessing_game-76d47656c615a8bd.4ywvypsd86lshzrb.rcgu.o" "C:\\Users\\Hyun\\OneDrive - skku.edu\\study_log\\210912~ 알고리즘\\doRust\\guessing_game\\target\\debug\\deps\\guessing_game-76d47656c615a8bd.50t4tbuzklbevc90.rcgu.o" "C:\\Users\\Hyun\\OneDrive - skku.edu\\study_log\\210912~ 알고리즘\\doRust\\guessing_game\\target\\debug\\deps\\guessing_game-76d47656c615a8bd.59cfjielgyzx6tmz.rcgu.o" "C:\\Users\\Hyun\\OneDrive - skku.edu\\study_log\\210912~ 알고리즘\\doRust\\guessing_game\\target\\debug\\deps\\guessing_game-76d47656c615a8bd.d6pzihmq0hvwebw.rcgu.o" "C:\\Users\\Hyun\\OneDrive - skku.edu\\study_log\\210912~ 알고리즘\\doRust\\guessing_game\\target\\debug\\deps\\guessing_game-76d47656c615a8bd.fkp93auyialdd7q.rcgu.o" "C:\\Users\\Hyun\\OneDrive - skku.edu\\study_log\\210912~ 알고리즘\\doRust\\guessing_game\\target\\debug\\deps\\guessing_game-76d47656c615a8bd.mx22hge6lmo4dnx.rcgu.o" "C:\\Users\\Hyun\\OneDrive - skku.edu\\study_log\\210912~ 알고 리즘\\doRust\\guessing_game\\target\\debug\\deps\\guessing_game-76d47656c615a8bd.5c7g9a6s1a3b0gl7.rcgu.o" "-L" "C:\\Users\\Hyun\\OneDrive - skku.edu\\study_log\\210912~ 알고리즘\\doRust\\guessing_game\\target\\debug\\deps" "-L" "C:\\Users\\Hyun\\scoop\\apps\\rust\\1.57.0\\lib\\rustlib\\x86_64-pc-windows-gnu\\lib" "-Wl,--start-group" "-Wl,-Bstatic" "C:\\Users\\Hyun\\scoop\\apps\\rust\\1.57.0\\lib\\rustlib\\x86_64-pc-windows-gnu\\lib\\libstd-57e8ea4e1cfb36e3.rlib" "C:\\Users\\Hyun\\scoop\\apps\\rust\\1.57.0\\lib\\rustlib\\x86_64-pc-windows-gnu\\lib\\libpanic_unwind-d50ed3cb69dbfa89.rlib" "C:\\Users\\Hyun\\scoop\\apps\\rust\\1.57.0\\lib\\rustlib\\x86_64-pc-windows-gnu\\lib\\libobject-db8fbc6e4b507d8c.rlib" "C:\\Users\\Hyun\\scoop\\apps\\rust\\1.57.0\\lib\\rustlib\\x86_64-pc-windows-gnu\\lib\\libmemchr-2c2fe1d9eecdd835.rlib" "C:\\Users\\Hyun\\scoop\\apps\\rust\\1.57.0\\lib\\rustlib\\x86_64-pc-windows-gnu\\lib\\libaddr2line-8e620bb89415248d.rlib" "C:\\Users\\Hyun\\scoop\\apps\\rust\\1.57.0\\lib\\rustlib\\x86_64-pc-windows-gnu\\lib\\libgimli-50c1bebcf1938271.rlib" "C:\\Users\\Hyun\\scoop\\apps\\rust\\1.57.0\\lib\\rustlib\\x86_64-pc-windows-gnu\\lib\\libstd_detect-1df005efff689fb6.rlib" "C:\\Users\\Hyun\\scoop\\apps\\rust\\1.57.0\\lib\\rustlib\\x86_64-pc-windows-gnu\\lib\\librustc_demangle-7bd71b39d5dd92f1.rlib" "C:\\Users\\Hyun\\scoop\\apps\\rust\\1.57.0\\lib\\rustlib\\x86_64-pc-windows-gnu\\lib\\libhashbrown-79c4ada05aad6e88.rlib" "C:\\Users\\Hyun\\scoop\\apps\\rust\\1.57.0\\lib\\rustlib\\x86_64-pc-windows-gnu\\lib\\librustc_std_workspace_alloc-cfc3e2e8bead46d2.rlib" "C:\\Users\\Hyun\\scoop\\apps\\rust\\1.57.0\\lib\\rustlib\\x86_64-pc-windows-gnu\\lib\\libunwind-adc2f2a5afea326c.rlib" "C:\\Users\\Hyun\\scoop\\apps\\rust\\1.57.0\\lib\\rustlib\\x86_64-pc-windows-gnu\\lib\\libcfg_if-d9c292e85ad6a944.rlib" "C:\\Users\\Hyun\\scoop\\apps\\rust\\1.57.0\\lib\\rustlib\\x86_64-pc-windows-gnu\\lib\\liblibc-fc23eff1f7c571db.rlib" "C:\\Users\\Hyun\\scoop\\apps\\rust\\1.57.0\\lib\\rustlib\\x86_64-pc-windows-gnu\\lib\\liballoc-2b42541821d9e283.rlib" "C:\\Users\\Hyun\\scoop\\apps\\rust\\1.57.0\\lib\\rustlib\\x86_64-pc-windows-gnu\\lib\\librustc_std_workspace_core-10202bb8c6593b6a.rlib" "C:\\Users\\Hyun\\scoop\\apps\\rust\\1.57.0\\lib\\rustlib\\x86_64-pc-windows-gnu\\lib\\libcore-0e8789dc8677c5cb.rlib" "-Wl,--end-group" "C:\\Users\\Hyun\\scoop\\apps\\rust\\1.57.0\\lib\\rustlib\\x86_64-pc-windows-gnu\\lib\\libcompiler_builtins-b7726d063fa88be4.rlib" "-Wl,-Bdynamic" "-lkernel32" "-lws2_32" "-lbcrypt" "-ladvapi32" "-luserenv" "-lkernel32" "-lgcc_eh" "-l:libpthread.a" "-lmsvcrt" "-lmingwex" "-lmingw32" "-lgcc" "-lmsvcrt" "-luser32" "-lkernel32" "-Wl,--nxcompat" "-L" "C:\\Users\\Hyun\\scoop\\apps\\rust\\1.57.0\\lib\\rustlib\\x86_64-pc-windows-gnu\\lib" "-o" "C:\\Users\\Hyun\\OneDrive - skku.edu\\study_log\\210912~ 알고리즘\\doRust\\guessing_game\\target\\debug\\deps\\guessing_game-76d47656c615a8bd.exe" "-Wl,--gc-sections" "-no-pie" "-nodefaultlibs" "C:\\Users\\Hyun\\scoop\\apps\\rust\\1.57.0\\lib\\rustlib\\x86_64-pc-windows-gnu\\lib\\rsend.o"
  = note: x86_64-w64-mingw32-gcc.exe: error: C:\Users\Hyun\OneDrive - skku.edu\study_log\210912~ 알고리즘\doRust\guessing_game\target\debug\deps\guessing_game-76d47656c615a8bd.10qd4t3vl5dggyii.rcgu.o: Invalid argument
          x86_64-w64-mingw32-gcc.exe: error: C:\Users\Hyun\OneDrive - skku.edu\study_log\210912~ 알고리즘\doRust\guessing_game\target\debug\deps\guessing_game-76d47656c615a8bd.16zw9wst24178ud4.rcgu.o: Invalid argument
          x86_64-w64-mingw32-gcc.exe: error: C:\Users\Hyun\OneDrive - skku.edu\study_log\210912~ 알고리즘\doRust\guessing_game\target\debug\deps\guessing_game-76d47656c615a8bd.1eoc6tyi8jkohxah.rcgu.o: Invalid argument
          x86_64-w64-mingw32-gcc.exe: error: C:\Users\Hyun\OneDrive - skku.edu\study_log\210912~ 알고리즘\doRust\guessing_game\target\debug\deps\guessing_game-76d47656c615a8bd.1hplge1zf5eguyyr.rcgu.o: Invalid argument
          x86_64-w64-mingw32-gcc.exe: error: C:\Users\Hyun\OneDrive - skku.edu\study_log\210912~ 알고리즘\doRust\guessing_game\target\debug\deps\guessing_game-76d47656c615a8bd.1ivijbprik886hmn.rcgu.o: Invalid argument
          x86_64-w64-mingw32-gcc.exe: error: C:\Users\Hyun\OneDrive - skku.edu\study_log\210912~ 알고리즘\doRust\guessing_game\target\debug\deps\guessing_game-76d47656c615a8bd.1xye7ppbvqcvmrv6.rcgu.o: Invalid argument
          x86_64-w64-mingw32-gcc.exe: error: C:\Users\Hyun\OneDrive - skku.edu\study_log\210912~ 알고리즘\doRust\guessing_game\target\debug\deps\guessing_game-76d47656c615a8bd.2gpcp77jxcamqu5p.rcgu.o: Invalid argument
          x86_64-w64-mingw32-gcc.exe: error: C:\Users\Hyun\OneDrive - skku.edu\study_log\210912~ 알고리즘\doRust\guessing_game\target\debug\deps\guessing_game-76d47656c615a8bd.2hvehzida7va9ohi.rcgu.o: Invalid argument
          x86_64-w64-mingw32-gcc.exe: error: C:\Users\Hyun\OneDrive - skku.edu\study_log\210912~ 알고리즘\doRust\guessing_game\target\debug\deps\guessing_game-76d47656c615a8bd.2ifonpkpv77sm38.rcgu.o: Invalid argument
          x86_64-w64-mingw32-gcc.exe: error: C:\Users\Hyun\OneDrive - skku.edu\study_log\210912~ 알고리즘\doRust\guessing_game\target\debug\deps\guessing_game-76d47656c615a8bd.2mensmmmn4q6gasd.rcgu.o: Invalid argument
          x86_64-w64-mingw32-gcc.exe: error: C:\Users\Hyun\OneDrive - skku.edu\study_log\210912~ 알고리즘\doRust\guessing_game\target\debug\deps\guessing_game-76d47656c615a8bd.2mwyj4c1fvk6o21u.rcgu.o: Invalid argument
          x86_64-w64-mingw32-gcc.exe: error: C:\Users\Hyun\OneDrive - skku.edu\study_log\210912~ 알고리즘\doRust\guessing_game\target\debug\deps\guessing_game-76d47656c615a8bd.2t18lbyuvd6isr13.rcgu.o: Invalid argument
          x86_64-w64-mingw32-gcc.exe: error: C:\Users\Hyun\OneDrive - skku.edu\study_log\210912~ 알고리즘\doRust\guessing_game\target\debug\deps\guessing_game-76d47656c615a8bd.2xl1pbs6nciq84uw.rcgu.o: Invalid argument
          x86_64-w64-mingw32-gcc.exe: error: C:\Users\Hyun\OneDrive - skku.edu\study_log\210912~ 알고리즘\doRust\guessing_game\target\debug\deps\guessing_game-76d47656c615a8bd.31ea220sa5g3iqm4.rcgu.o: Invalid argument
          x86_64-w64-mingw32-gcc.exe: error: C:\Users\Hyun\OneDrive - skku.edu\study_log\210912~ 알고리즘\doRust\guessing_game\target\debug\deps\guessing_game-76d47656c615a8bd.34i1dg8plnojdg.rcgu.o: Invalid argument
          x86_64-w64-mingw32-gcc.exe: error: C:\Users\Hyun\OneDrive - skku.edu\study_log\210912~ 알고리즘\doRust\guessing_game\target\debug\deps\guessing_game-76d47656c615a8bd.37shp4gq694hm0sb.rcgu.o: Invalid argument
          x86_64-w64-mingw32-gcc.exe: error: C:\Users\Hyun\OneDrive - skku.edu\study_log\210912~ 알고리즘\doRust\guessing_game\target\debug\deps\guessing_game-76d47656c615a8bd.3h0d9fa57i9q049v.rcgu.o: Invalid argument
          x86_64-w64-mingw32-gcc.exe: error: C:\Users\Hyun\OneDrive - skku.edu\study_log\210912~ 알고리즘\doRust\guessing_game\target\debug\deps\guessing_game-76d47656c615a8bd.3x091ods49juvf29.rcgu.o: Invalid argument
          x86_64-w64-mingw32-gcc.exe: error: C:\Users\Hyun\OneDrive - skku.edu\study_log\210912~ 알고리즘\doRust\guessing_game\target\debug\deps\guessing_game-76d47656c615a8bd.4yolf9p09igensl9.rcgu.o: Invalid argument
          x86_64-w64-mingw32-gcc.exe: error: C:\Users\Hyun\OneDrive - skku.edu\study_log\210912~ 알고리즘\doRust\guessing_game\target\debug\deps\guessing_game-76d47656c615a8bd.4ywvypsd86lshzrb.rcgu.o: Invalid argument
          x86_64-w64-mingw32-gcc.exe: error: C:\Users\Hyun\OneDrive - skku.edu\study_log\210912~ 알고리즘\doRust\guessing_game\target\debug\deps\guessing_game-76d47656c615a8bd.50t4tbuzklbevc90.rcgu.o: Invalid argument
          x86_64-w64-mingw32-gcc.exe: error: C:\Users\Hyun\OneDrive - skku.edu\study_log\210912~ 알고리즘\doRust\guessing_game\target\debug\deps\guessing_game-76d47656c615a8bd.59cfjielgyzx6tmz.rcgu.o: Invalid argument
          x86_64-w64-mingw32-gcc.exe: error: C:\Users\Hyun\OneDrive - skku.edu\study_log\210912~ 알고리즘\doRust\guessing_game\target\debug\deps\guessing_game-76d47656c615a8bd.d6pzihmq0hvwebw.rcgu.o: Invalid argument
          x86_64-w64-mingw32-gcc.exe: error: C:\Users\Hyun\OneDrive - skku.edu\study_log\210912~ 알고리즘\doRust\guessing_game\target\debug\deps\guessing_game-76d47656c615a8bd.fkp93auyialdd7q.rcgu.o: Invalid argument
          x86_64-w64-mingw32-gcc.exe: error: C:\Users\Hyun\OneDrive - skku.edu\study_log\210912~ 알고리즘\doRust\guessing_game\target\debug\deps\guessing_game-76d47656c615a8bd.mx22hge6lmo4dnx.rcgu.o: Invalid argument
          x86_64-w64-mingw32-gcc.exe: error: C:\Users\Hyun\OneDrive - skku.edu\study_log\210912~ 알고리즘\doRust\guessing_game\target\debug\deps\guessing_game-76d47656c615a8bd.5c7g9a6s1a3b0gl7.rcgu.o: Invalid argument

error: linking with `x86_64-w64-mingw32-gcc` failed: exit code: 1

상황

rustc에 cargo를 통해 폴더를 생성해서 간단한 코드 작성이후에 cargo run을 실행시켰더니 다음과 같은 오류가 발생하였다.

window환경에서 진행중이라, scoop을 통해 rust를 설치해주었고, vscode의 code runner로는 잘 돌아가서 cargo에서 linking을 제대로 해주지 못하고 있나 생각하는 상황이다.

https://github.com/rust-lang/rust/issues/91146 rustc 깃헙프로젝트에 동일한 문제로 issue를 올린 사람이 있다.

원인

폴더에 한글 경로가 있어서 문제였다.

해결법

위에 에러코드를 확인해보면 경로에 210912~ 알고리즘이라는 한글이 포함된 경로가 있다. 해당 부분을 영어로 변경해주었다.

일반적이라면 mingw과 연결되지 않아서 생기는 문제인 것같았다. scoop에는 mingw-w64가 존재하지 않아서 choco를 설치해서 설치를 해보는 것을 추천한다.

https://community.chocolatey.org/packages/mingw

참고자료

github issue 같은 내용 : https://github.com/rust-lang/rust/issues/91146

config로 해결하고자하는 : https://users.rust-lang.org/t/linking-with-gcc-failed-exit-code-1/34124/8

mingw-w64는 다른 버젼이다 : https://stackoverflow.com/questions/39422894/mingw-x86-64-w64-mingw32-gcc-not-found

mingw 새버젼 설치 : https://stackoverflow.com/questions/65740349/installed-mingw64-cant-find-make-or-mingw-get

초코,스쿱 설치 : https://dev.to/bowmanjd/chocolatey-vs-scoop-package-managers-for-windows-2kik

728x90
반응형