簡體   English   中英

g++:無法執行'DIRECTORY/collect2.exe':CreateProcess:沒有這樣的文件或目錄

[英]g++ :cannot execute ‘DIRECTORY/collect2.exe’:CreateProcess: No such file or directory

當我使用以下命令編譯 c++ 和 c 文件時:

g++ io.c *.cpp -o main  -D__STDC_FORMAT_MACROS

發生錯誤:

g++.exe: fatal error:cannot execute ‘C:/TDM-GCC-32/bin/../libexec/gcc/mingw32/9.2.0/collect2.exe’: CreateProcess: No such file or directory

實際上, collect2.exe存在於正確的目錄中。 我已經嘗試了在線提供的所有解決方案,但沒有一個有效。(等設置/清除環境值,嘗試其他版本的 mingw32 ...)我能想到的唯一原因是g++.exe在目錄中使用/ , 而 windows 使用\代替。 那么這個錯誤還有其他解決方案嗎?

LeafFourth 在這篇文章中為我確定了這一點: https://github.com/kriscross07/atom-gpp-compiler/issues/26

LeafFourth commented on Mar 23
I have experienced this problem before. The root cause is an exe file was unziped failed with the size zero. I tried another unzip tool to solved it.

For the problem, to know how it happened is important:
CreateProcess is a API to create a process, so the error indicated that the image file used to create the process may not exist.

How to solve it:
Add "-v" flags to run gcc/g++ to compile and then, the verbose log shows. We can find which file not exists. If nothing goes wrong, we can just run the last command in the verbose log with flag "-v" to continue to check recursively.

我是如何解決這個問題的。

一個。 將 -v 添加到編譯命令:
c:\Programs\gcc-arm-9.2-2019.12-mingw-w64-i686-arm-none-linux-gnueabihf\bin\arm-none-linux-gnueabihf-gcc test5.Z4A8A08F09D37B7379v5364903F新建44A8A08F09D37B7379v5364903F

Note: test5.c was a simple main() with no functions.

output was messy, finally ending in 

    c:/programs/gcc-arm-9.2-2019.12-mingw-w64-i686-arm-none-linux-gnueabihf/bin/../libexec/gcc/arm-none-linux-gnueabihf/9.2.1/collect2.exe -plugin c:/programs/gcc-arm-9.2-2019.12-mingw-w64-i686-arm-none-linux-gnueabihf/bin/../libexec/gcc/arm-none-linux-gnueabihf/9.2.1/liblto_plugin-0.dll -plugin-opt=c:/programs/gcc-arm-9.2-2019.12-mingw-w64-i686-arm-none-linux-gnueabihf/bin/../libexec/gcc/arm-none-linux-gnueabihf/9.2.1/lto-wrapper.exe -plugin-opt=-fresolution=C:\Users\pops\AppData\Local\Temp\ccTNEjZv.res -plugin-opt=-pass-through=-lgcc -plugin-opt=-pass-through=-lgcc_s -plugin-opt=-pass-through=-lc -plugin-opt=-pass-through=-lgcc -plugin-opt=-pass-through=-lgcc_s --sysroot=c:\programs\gcc-arm-9.2-2019.12-mingw-w64-i686-arm-none-linux-gnueabihf\bin\../arm-none-linux-gnueabihf/libc --eh-frame-hdr -dynamic-linker /lib/ld-linux-armhf.so.3 -X -m armelf_linux_eabi -o test5.out c:/programs/gcc-arm-9.2-2019.12-mingw-w64-i686-arm-none-linux-gnueabihf/bin/../arm-none-linux-gnueabihf/libc/usr/lib/crt1.o c:/programs/gcc-arm-9.2-2019.12-mingw-w64-i686-arm-none-linux-gnueabihf/bin/../arm-none-linux-gnueabihf/libc/usr/lib/crti.o c:/programs/gcc-arm-9.2-2019.12-mingw-w64-i686-arm-none-linux-gnueabihf/bin/../lib/gcc/arm-none-linux-gnueabihf/9.2.1/crtbegin.o -Lc:/programs/gcc-arm-9.2-2019.12-mingw-w64-i686-arm-none-linux-gnueabihf/bin/../lib/gcc/arm-none-linux-gnueabihf/9.2.1 -Lc:/programs/gcc-arm-9.2-2019.12-mingw-w64-i686-arm-none-linux-gnueabihf/bin/../lib/gcc -Lc:/programs/gcc-arm-9.2-2019.12-mingw-w64-i686-arm-none-linux-gnueabihf/bin/../lib/gcc/arm-none-linux-gnueabihf/9.2.1/../../../../arm-none-linux-gnueabihf/lib -Lc:/programs/gcc-arm-9.2-2019.12-mingw-w64-i686-arm-none-linux-gnueabihf/bin/../arm-none-linux-gnueabihf/libc/lib -Lc:/programs/gcc-arm-9.2-2019.12-mingw-w64-i686-arm-none-linux-gnueabihf/bin/../arm-none-linux-gnueabihf/libc/usr/lib C:\Users\pops\AppData\Local\Temp\ccjF1go9.o -lgcc --push-state --as-needed -lgcc_s --pop-state -lc -lgcc --push-state --as-needed -lgcc_s --pop-state c:/programs/gcc-arm-9.2-2019.12-mingw-w64-i686-arm-none-linux-gnueabihf/bin/../lib/gcc/arm-none-linux-gnueabihf/9.2.1/crtend.o c:/programs/gcc-arm-9.2-2019.12-mingw-w64-i686-arm-none-linux-gnueabihf/bin/../arm-none-linux-gnueabihf/libc/usr/lib/crtn.o
    collect2.exe: fatal error: CreateProcess: No such file or directory
    compilation terminated.
    

灣。 我驗證了所有列出的文件 - 檢查了路徑並看到了它們的存在。 注意:最初,我並沒有真正查看文件大小(我通常不顯示它)

c。 請注意,*.DLL 文件也調用其他函數/庫。 所以你可能沒有看到一切。 驗證所有文件可能是一項非常艱巨的任務。

d。 我終於注意到我的主 bin 文件沒有正確安裝。 見圖片。

顯然不是一個好的安裝

>   proper install should have files with size > 0 Kbytes.

改進了我的主要 bin 可執行文件的安裝

e. 解決方案是重新安裝 MinGW 工具。 簡單的編譯現在可以正常工作。

好吧,我終於成功地用Visual Studio編譯了源文件。 這不是這個問題的答案,但如果沒有找到其他解決方案,這是一條出路。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM