問題描述
我用 Code::Blocks 用 C++ 創建了一個簡單的程序.
如果我從 Code::Blocks 運行它,它可以正常工作;但是如果我通過雙擊可執行文件來運行它,則會彈出一個帶有此消息的窗口:
<塊引用>程序無法啟動,因為您的計算機缺少 libgcc_s_dw2-1.dll.
嘗試重新安裝程序以解決此問題.
那么,問題是什么?我該怎么做才能修復它?
我認為這是 MinGW/gcc 編譯器問題,而不是 Microsoft Visual Studio 設置.
libgcc_s_dw2-1.dll
應該在編譯器的 bin 目錄中.您可以將此目錄添加到您的 PATH 環境變量以進行運行時鏈接,或者您可以通過在編譯器標志中添加-static-libgcc -static-libstdc++"來避免該問題.
如果您打算分發可執行文件,則后者可能最有意義.如果您只打算在自己的機器上運行它,那么更改 PATH 環境變量是一個有吸引力的選擇(減少可執行文件的大小).
更新:
根據 Greg Treleaven 的反饋(見下面的評論),我添加了以下鏈接:
[Code::Blocks項目構建選項"的屏幕截圖]
[GNU gcc 鏈接選項]>
后面的討論包括 -static-libgcc
和 -static-libstdc++
鏈接器選項.
I have created a simple program in C++ with Code::Blocks.
If I run it from Code::Blocks, it works correctly; but if I run it by doubleclicking on the executable file, a window pops up with this message:
The program can't start because libgcc_s_dw2-1.dll is missing from your computer.
Try reinstalling the program to fix this problem.
So, what is the problem? What do I have to do to fix it?
I believe this is a MinGW/gcc compiler issue, rather than a Microsoft Visual Studio setup.
The libgcc_s_dw2-1.dll
should be in the compiler's bin directory. You can add this directory to your PATH environment variable for runtime linking, or you can avoid the problem by adding "-static-libgcc -static-libstdc++" to your compiler flags.
If you plan to distribute the executable, the latter probably makes the most sense. If you only plan to run it on your own machine, the changing the PATH environment variable is an attractive option (keeps down the size of the executable).
Updated:
Based on feedback from Greg Treleaven (see comments below), I'm adding links to:
[Screenshot of Code::Blocks "Project build options"]
[GNU gcc link options]
The latter discussion includes -static-libgcc
and -static-libstdc++
linker options.
這篇關于程序無法啟動,因為缺少 libgcc_s_dw2-1.dll的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!