• <bdo id='58zHb'></bdo><ul id='58zHb'></ul>
      <tfoot id='58zHb'></tfoot>
      <legend id='58zHb'><style id='58zHb'><dir id='58zHb'><q id='58zHb'></q></dir></style></legend>

      <small id='58zHb'></small><noframes id='58zHb'>

    1. <i id='58zHb'><tr id='58zHb'><dt id='58zHb'><q id='58zHb'><span id='58zHb'><b id='58zHb'><form id='58zHb'><ins id='58zHb'></ins><ul id='58zHb'></ul><sub id='58zHb'></sub></form><legend id='58zHb'></legend><bdo id='58zHb'><pre id='58zHb'><center id='58zHb'></center></pre></bdo></b><th id='58zHb'></th></span></q></dt></tr></i><div id='58zHb'><tfoot id='58zHb'></tfoot><dl id='58zHb'><fieldset id='58zHb'></fieldset></dl></div>

        无论代码如何,MinGW .exe 都需要一些 gcc dll?

        时间:2023-08-29
      1. <legend id='Z23E8'><style id='Z23E8'><dir id='Z23E8'><q id='Z23E8'></q></dir></style></legend>

        • <i id='Z23E8'><tr id='Z23E8'><dt id='Z23E8'><q id='Z23E8'><span id='Z23E8'><b id='Z23E8'><form id='Z23E8'><ins id='Z23E8'></ins><ul id='Z23E8'></ul><sub id='Z23E8'></sub></form><legend id='Z23E8'></legend><bdo id='Z23E8'><pre id='Z23E8'><center id='Z23E8'></center></pre></bdo></b><th id='Z23E8'></th></span></q></dt></tr></i><div id='Z23E8'><tfoot id='Z23E8'></tfoot><dl id='Z23E8'><fieldset id='Z23E8'></fieldset></dl></div>
          <tfoot id='Z23E8'></tfoot>

                <bdo id='Z23E8'></bdo><ul id='Z23E8'></ul>

                <small id='Z23E8'></small><noframes id='Z23E8'>

                    <tbody id='Z23E8'></tbody>
                  本文介绍了无论代码如何,MinGW .exe 都需要一些 gcc dll?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  使用 MinGW 编译时,我必须在 exe 运行之前从 MinGW bin 目录中复制某些 dll 文件(即使使用-static"和/或-static-libstdc++"也是如此.)我该如何改变?是否有我必须使用的特殊版本的 MinGW?最终,我希望能够只使用目录中的 exe(并且没有设置 Windows 环境变量)来运行程序.这些文件是:

                  When compiling with MinGW, I have to copy over certain dll files from the MinGW bin directory before the exe will run (Even when using "-static" and/or "-static-libstdc++".) How do I change that? Is there a special build of MinGW that I have to use? Ultimately I want to be able to run the program with nothing but the exe in the directory (and no windows environment variables set.) These File's are:

                  • libstdc++-6.dll
                  • libgcc_s_seh-1.dll
                  • libwinpthread-1.dll

                  这是我休耕的完整步骤列表:

                  And here is the complete list of step's I fallow:

                  1. 打开代码::块
                  2. 选择文件->新建->项目->控制台"
                  3. 填写项目Hello World"的项目设置
                  4. 右键单击项目->构建选项...->Hello World(根目标)->其他选项
                  5. 在已设置的-fexceptions"下输入-static"(或-static-libstdc++")
                  6. CTRL-F9 : 构建项目(不执行)
                  7. 在 Windows 资源管理器中导航到并运行构建的Hello World.exe"文件.
                  8. 当弹出消息错误:您的计算机缺少 libstdc++-6.dll"时,单击确定".
                  9. 将libstdc++-6.dll"从/MinGW/bin/目录复制到Hello World.exe"目录中.
                  10. 运行Hello World.exe"
                  11. 对于显示错误:您的计算机中缺少 libgcc_s_seh-1.dll"的消息,单击确定".
                  12. 将libgcc_s_seh-1.dll"复制到Hello World.exe"目录中.
                  13. 重复并最终复制libwinpthread-1.dll".
                  14. 查看消息

                  1. Open Up Code::Blocks
                  2. Select "File->New->Project->Console"
                  3. Fill out the project settings for project "Hello World"
                  4. Right click Project->Build Options...->Hello World (Root target)->Other Options
                  5. Enter "-static" (or "-static-libstdc++") under the already set "-fexceptions"
                  6. CTRL-F9 : Build Project (Without executing)
                  7. Navigate to, in Windows Explorer, and run the built "Hello World.exe" file.
                  8. Click "OK" when a message pop's up saying "Error: libstdc++-6.dll is missing from your computer."
                  9. Copy "libstdc++-6.dll" from the /MinGW/bin/ directory, into the "Hello World.exe" directory.
                  10. Run "Hello World.exe"
                  11. Click "OK" for the message saying "Error: libgcc_s_seh-1.dll is missing from your computer."
                  12. Copy "libgcc_s_seh-1.dll" into the "Hello World.exe" directory.
                  13. Repeat and end up copying "libwinpthread-1.dll" over aswell.
                  14. View the message

                  Hello World!
                  

                  我的命令行是:

                  g++.exe -Wall -fexceptions -static -static-libgcc -static-libstdc++ -g -static-libgcc -static-libstdc++ -L. -c "C:Users\______DesktopHello Worldmain.cpp" -o objDebugmain.o
                  g++.exe -o "binDebugHello World.exe" objDebugmain.o
                  

                  需要上面提到的所有dll文件.而且,为了安全起见,代码是:

                  With all the dll files mentioned above required. And, just to be safe, the code is:

                  // main.cpp
                  #include <iostream>
                  
                  using namespace std;
                  
                  int main()
                  {
                      cout << "Hello world!" << endl;
                      return 0;
                  }
                  

                  推荐答案

                  你的命令错了!

                  转到 main.cpp 文件所在的目录,然后尝试以下操作.

                  Go to the directory where your main.cpp file is, and try the following.

                  g++.exe -Wall -c -g main.cpp -o objDebugmain.o
                  g++.exe -static -static-libgcc -static-libstdc++ -o "binDebugHello World.exe" objDebugmain.o
                  

                  那么您将不再需要复制 DLL(用于您的 Hello World 程序).

                  then you'll no longer need to copy the DLLs (for your Hello World program).

                  其他注意事项:

                  MinGW安装说明推荐设置

                  The MinGW installation instructions recommends setting

                  c:minGW;c:MinGWin;
                  

                  到 PATH 环境变量.

                  to the PATH environment variable.

                  通常是

                  -static -static-libgcc -static-libstdc++
                  

                  链接器选项应该可以工作(一次尝试所有 3 个).但不适用于 libwinpthread-1.dll.

                  linker options should work (try all 3 of them at once). But not for libwinpthread-1.dll.

                  另外,在重新编译之前尝试clean.

                  Also, try to clean before recompiling.

                  没有-static-something"命令.

                  There's no "-static-something" command.

                  只有标准库 libgcclibstdc++ 可以设置为静态链接.

                  Only standard libraries libgcc and libstdc++ can be set to static linking.

                  对于其他库,您首先使用-static"切换到静态链接,然后列出要包含在单独命令中的库,即-lpthread".

                  For other libraries, you first switch to static linking with "-static" and then list the libraries to include with separate commands, i.e. "-lpthread".

                  Cmake 用户应该尝试添加:

                  set(CMAKE_CXX_STANDARD_LIBRARIES "-static-libgcc -static-libstdc++ -lwsock32 -lws2_32 ${CMAKE_CXX_STANDARD_LIBRARIES}")
                  
                  set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,-Bstatic,--whole-archive -lwinpthread -Wl,--no-whole-archive")
                  

                  这篇关于无论代码如何,MinGW .exe 都需要一些 gcc dll?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:使用清单的 DLL 重定向 下一篇:带有 Python 嵌入的 C++:如果未安装 Python,则会崩溃

                  相关文章

                    <bdo id='iBZ5B'></bdo><ul id='iBZ5B'></ul>
                  <tfoot id='iBZ5B'></tfoot>

                    <i id='iBZ5B'><tr id='iBZ5B'><dt id='iBZ5B'><q id='iBZ5B'><span id='iBZ5B'><b id='iBZ5B'><form id='iBZ5B'><ins id='iBZ5B'></ins><ul id='iBZ5B'></ul><sub id='iBZ5B'></sub></form><legend id='iBZ5B'></legend><bdo id='iBZ5B'><pre id='iBZ5B'><center id='iBZ5B'></center></pre></bdo></b><th id='iBZ5B'></th></span></q></dt></tr></i><div id='iBZ5B'><tfoot id='iBZ5B'></tfoot><dl id='iBZ5B'><fieldset id='iBZ5B'></fieldset></dl></div>

                      <small id='iBZ5B'></small><noframes id='iBZ5B'>

                    1. <legend id='iBZ5B'><style id='iBZ5B'><dir id='iBZ5B'><q id='iBZ5B'></q></dir></style></legend>