C++ 找不到 libstdc++-6.dll

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/6404636/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-28 20:04:32  来源:igfitidea点击:

libstdc++-6.dll not found

c++mingwlibraries

提问by Molmasepic

I have been working on a project (a game to be specific) and I feel that I should start over with different libraries. So when doing this I reinstalled Code::Blocksand setup my new libraries and includes.

我一直在做一个项目(具体来说是一个游戏),我觉得我应该从不同的库重新开始。因此,在执行此操作时,我重新安装了Code::Blocks并设置了我的新库和包含。

But as of now Im having a problem starting u[ my new project to test if all of the includes work. This problem is: libstdc++-6.dll was not found.At first i wondered if I could just find this file online, but its nowhere to be found(or at least the many places I have searched...) Soon after, I tried loading up my old project, and the same problem happened again(wierd... ._.) I was thinking its maybe my compiler, so I used my older compiler and it did the same thing! At this moment I held the problem off for tomorrow(which is today)

但是到目前为止,我在启动您时遇到了问题[我的新项目来测试所有包含的内容是否有效。这个问题是:libstdc++-6.dll was not found.起初我想知道我是否可以在网上找到这个文件,但它无处可寻(或者至少我搜索过的许多地方......)不久之后,我尝试加载我的旧项目,并且同样的问题再次发生(奇怪... ._.)我在想它可能是我的编译器,所以我使用了我的旧编译器并且它做了同样的事情!此刻我把问题推迟到明天(也就是今天)

So my question is: If anyone else had this problem, how would you solve it?

所以我的问题是:如果其他人有这个问题,你会如何解决?

Im using Code::Blocks with MinGW as the compiler on Windows Vista 32 bit.

我在 Windows Vista 32 位上使用带有 MinGW 的 Code::Blocks 作为编译器。

*****EDIT*****

*****编辑*****

Here are the Build options in my project. Note that these are the settings in the Project, not the global compiler:

这是我的项目中的构建选项。请注意,这些是项目中的设置,而不是全局编译器:

In (project name)->Compiler settings->Otehr options:

在(项目名称)->编译器设置->其他选项中:

(I use //to seperate the commands)

(我//用来分隔命令)

-mthreads//
-fmessage-length=0//
-fexceptions//
-fident//

In (project name)->Compiler settings->#define:

在(项目名称)->编译器设置->#define中:

WIN32//
_WINDOWS//

In (project name)->Linker settings->Other linker options:

在(项目名称)->链接器设置->其他链接器选项中:

-static-libstdc++//
-static-libgcc//
-Wl,--enable-auto-image-base//
-Wl,--add-stdcall-alias//
-Wl,--enable-auto-import//

In linker->link libraries i have various links to files with a .aextension, these files include Bullet PHysics, Ogre3D, and SFML

在链接器->链接库中,我有各种带有.a扩展名的文件链接,这些文件包括 Bullet PHYsics、Ogre3D 和 SFML

In the search directories i have links to the MinGW/bin, and the MinGW/lib directories, along with other links to different libraries.

在搜索目录中,我有指向 MinGW/bin 和 MinGW/lib 目录的链接,以及指向不同库的其他链接。

My Compiler is MinGW, a GNU GCC compiler for windows 32 bit. and the IDE is Codeblocks. Also note that in Debug and Release settings on the project, there is nothing.

我的编译器是 MinGW,一个适用于 Windows 32 位的 GNU GCC 编译器。IDE 是 Codeblocks。另请注意,在项目的 Debug 和 Release 设置中,没有任何内容。

Most of these setings are also pieces that i got from the Ogre3D Application setup tutorialif that is of any help.

如果有任何帮助,这些设置中的大多数也是我从Ogre3D 应用程序设置教程中获得的部分

回答by Kerrek SB

If you are using MingW to compile C++ code on Windows, you may like to add the options -static-libgccand -static-libstdc++to link the C and C++ standard libraries statically and thus remove the need to carry around any separate copies of those. Version management of libraries is a pain in Windows, so I've found this approach the quickest and cleanest solution to creating Windows binaries.

如果您使用 MingW 在 Windows 上编译 C++ 代码,您可能希望添加选项-static-libgcc-static-libstdc++静态链接 C 和 C++ 标准库,从而消除携带这些选项的任何单独副本的需要。库的版本管理在 Windows 中很麻烦,所以我发现这种方法是创建 Windows 二进制文件的最快捷、最干净的解决方案。

回答by Valkea

As far as I know, this is the C++ Runtime Library. So it depends on the compiler you use to create your program (A new version will include some C++0x stuff, an older version will probably not for instance. It depends of the compiler and of its version).

据我所知,这是 C++ 运行时库。因此,这取决于您用于创建程序的编译器(新版本将包含一些 C++0x 内容,例如旧版本可能不会。这取决于编译器及其版本)。

If you use MinGW then you should use the libstdc++-6.dll found into the folder of this compiler. MinGW/bin foldershould be the place to search for it on your computer.

如果您使用 MinGW,那么您应该使用此编译器文件夹中的 libstdc++-6.dll。MinGW/bin 文件夹应该是在您的计算机上搜索它的地方。

If you copy this file in the same directory as your executable, it should be OK.

如果您将此文件复制到与可执行文件相同的目录中,则应该没问题。

回答by Tamir

Simply removing libstdc++-6.dll.a \ libstdc++.dll.a from the mingw directory fixes this.

只需从 mingw 目录中删除 libstdc++-6.dll.a \ libstdc++.dll.a 即可解决此问题。

I tried using the flag -static-libstdc++ but this did not work for me. I found the solution in: http://ghc.haskell.org/trac/ghc/ticket/4468#

我尝试使用标志 -static-libstdc++ 但这对我不起作用。我在以下位置找到了解决方案:http: //ghc.haskell.org/trac/ghc/ticket/4468#

回答by nckturner

This error also occurred when I compiled with MinGW using gcc with the following options: -lstdc++ -lm, rather than g++

当我使用带有以下选项的 gcc 使用 MinGW 编译时,也会发生此错误: -lstdc++ -lm, 而不是 g++

I did not notice these options, and added: -static-libgcc -static-libstdc++

我没有注意到这些选项,并补充说: -static-libgcc -static-libstdc++

I still got the error, and finally realized I was using gcc, and changed the compiler to g++ and removed -stdc++ and -lm, and everything linked fine.

我仍然得到错误,终于意识到我正在使用gcc,并将编译器更改为g++并删除-stdc++ and -lm,并且一切链接正常。

(I was using LINK.c rather than LINK.cpp... use make -pn | lessto see what everything does!)

(我使用的是 LINK.c 而不是 LINK.cpp ......make -pn | less用来看看一切都做了什么!)

I don't know why the previous author was using gcc with -stdc++. I don't see any reason not to use g++ which will link with stdc++ automatically... and as far as I know, provide other benefits (it is the c++ compiler after all).

我不知道为什么以前的作者将 gcc 与 -stdc++ 一起使用。我看不出有任何理由不使用 g++ ,它会自动与 stdc++ 链接......据我所知,提供其他好处(毕竟它是 c++ 编译器)。

回答by user11335559

useful to windows users who use eclipse for c/c++ but run *.exe file and get an error: "missing libstdc++6.dll"

对于使用 eclipse for c/c++ 但运行 *.exe 文件并得到错误:“missing libstdc++6.dll”的 Windows 用户很有用

4 ways to solve it

4种方法解决

  1. Eclipse ->"Project" -> "Properties" -> "C/C++ Build" -> "Settings" -> "Tool Settings" -> "MinGW C++ Linker" -> "Misscellaneous" -> "Linker flags" (add '-static' to it)

  2. Add '{{the path where your MinGW was installed}}/bin' to current user environment variable - "Path" in Windows, then reboot eclipse, and finally recompile.

  3. Add '{{the path where your MinGW was installed}}/bin' to Windows environment variable - "Path", then reboot eclipse, and finally recompile.

  4. Copy the file "libstdc++-6.dll" to the path where the *.exe file is running, then rerun. (this is not a good way)

  1. Eclipse ->“项目”->“属性”->“C/C++ 构建”->“设置”->“工具设置”->“MinGW C++ 链接器”->“杂项”->“链接器标志”(添加'-static' 到它)

  2. 将'{{安装MinGW的路径}}/bin'添加到当前用户环境变量-Windows中的“路径”,然后重新启动eclipse,最后重新编译。

  3. 将'{{安装MinGW的路径}}/bin'添加到Windows环境变量-“路径”中,然后重启eclipse,最后重新编译。

  4. 将文件“libstdc++-6.dll”复制到*.exe文件运行的路径,然后重新运行。(这不是一个好方法)

Note: the file "libstdc++-6.dll" is in the folder '{{the path where your MinGW was installed}}/bin'

注意:文件“libstdc++-6.dll”位于“{{安装MinGW的路径}}/bin”文件夹中

回答by Rudraksha

I placed the libstdc++-6.dll file in the same folder where exe file is generated.

我将 libstdc++-6.dll 文件放在生成 exe 文件的同一文件夹中。

回答by Dan Ortega

You only need to add your "mingw-install-directory"/bin/ to your Path in your System environment variables ... that's it !!

您只需要将您的“mingw-install-directory”/bin/ 添加到您的系统环境变量中的路径中......就是这样!

回答by Zurab Kargareteli

I use Eclipse under Fedora 20 with MinGW for cross compile. Use these settings and the program won't ask for libstdc++-6.dll any more.

我在 Fedora 20 下使用 Eclipse 和 MinGW 进行交叉编译。使用这些设置,程序将不再需要 libstdc++-6.dll。

Project type - Cross GCC

项目类型 - 跨 GCC

Cross Settings

交叉设置

  • Prefix: x86_64-w64-mingw32-
  • Path: /usr/bin
  • 前缀:x86_64-w64-mingw32-
  • 路径:/usr/bin

Cross GCC Compiler

跨 GCC 编译器

  • Command: gcc

  • All Options: -I/usr/x86_64-w64-mingw32/sys-root/mingw/include -O3 -Wall -c -fmessage-length=0

  • Includes: /usr/x86_64-w64-mingw32/sys-root/mingw/include

  • 命令:gcc

  • 所有选项:-I/usr/x86_64-w64-mingw32/sys-root/mingw/include -O3 -Wall -c -fmessage-length=0

  • 包括:/usr/x86_64-w64-mingw32/sys-root/mingw/include

Cross G++ Compiler

跨 G++ 编译器

  • Command: g++

  • All Options: -I/usr/x86_64-w64-mingw32/sys-root/mingw/include -O3 -Wall -c -fmessage-length=0

  • Includes: /usr/x86_64-w64-mingw32/sys-root/mingw/include

  • 命令:g++

  • 所有选项:-I/usr/x86_64-w64-mingw32/sys-root/mingw/include -O3 -Wall -c -fmessage-length=0

  • 包括:/usr/x86_64-w64-mingw32/sys-root/mingw/include

Cross G++ Linker

交叉 G++ 链接器

  • Command: g++ -static-libstdc++ -static-libgcc

  • All Options: -L/usr/x86_64-w64-mingw32/sys-root/mingw/lib -L/usr/x86_64-w64-mingw32/sys-root/mingw/bin

  • Library search path (-L):

    /usr/x86_64-w64-mingw32/sys-root/mingw/lib

    /usr/x86_64-w64-mingw32/sys-root/mingw/bin

  • 命令:g++ -static-libstdc++ -static-libgcc

  • 所有选项:-L/usr/x86_64-w64-mingw32/sys-root/mingw/lib -L/usr/x86_64-w64-mingw32/sys-root/mingw/bin

  • 库搜索路径(-L):

    /usr/x86_64-w64-mingw32/sys-root/mingw/lib

    /usr/x86_64-w64-mingw32/sys-root/mingw/bin