問題描述
我用 Code::Blocks 用 C++ 創(chuàng)建了一個(gè)簡(jiǎn)單的程序.
如果我從 Code::Blocks 運(yùn)行它,它可以正常工作;但是如果我通過雙擊可執(zhí)行文件來運(yùn)行它,則會(huì)彈出一個(gè)帶有此消息的窗口:
<塊引用>程序無法啟動(dòng),因?yàn)槟挠?jì)算機(jī)缺少 libgcc_s_dw2-1.dll.
嘗試重新安裝程序以解決此問題.
那么,問題是什么?我該怎么做才能修復(fù)它?
我認(rèn)為這是 MinGW/gcc 編譯器問題,而不是 Microsoft Visual Studio 設(shè)置.
libgcc_s_dw2-1.dll
應(yīng)該在編譯器的 bin 目錄中.您可以將此目錄添加到您的 PATH 環(huán)境變量以進(jìn)行運(yùn)行時(shí)鏈接,或者您可以通過在編譯器標(biāo)志中添加-static-libgcc -static-libstdc++"來避免該問題.
如果您打算分發(fā)可執(zhí)行文件,則后者可能最有意義.如果您只打算在自己的機(jī)器上運(yùn)行它,那么更改 PATH 環(huán)境變量是一個(gè)有吸引力的選擇(減少可執(zhí)行文件的大小).
更新:
根據(jù) Greg Treleaven 的反饋(見下面的評(píng)論),我添加了以下鏈接:
[Code::Blocks項(xiàng)目構(gòu)建選項(xiàng)"的屏幕截圖]
[GNU gcc 鏈接選項(xiàng)]>
后面的討論包括 -static-libgcc
和 -static-libstdc++
鏈接器選項(xiàng).
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.
這篇關(guān)于程序無法啟動(dòng),因?yàn)槿鄙?libgcc_s_dw2-1.dll的文章就介紹到這了,希望我們推薦的答案對(duì)大家有所幫助,也希望大家多多支持html5模板網(wǎng)!