Linking Libraries in Xcode - c++

I'm using a powerbook (osx 10.5) and recently downloaded and installed FFTW 3.2 (link text). I've been able to compile and run some simple programs based on the online tutorial using the terminal:
g++ main.cpp -lfftw3 -lm
However, I can't get the same program to compile in Xcode. I get a linking error, "symbol(s) not found". There is a file called libfftw3.a in /usr/local/lib. How can this be linked? Furthermore, apparently the libraries have to be linked in a particular order, i.e. see: link text
thanks for any help

To link to a .a library like this in Xcode you need to:
Double-click on your target or application in Xcode to open the Info window
Switch to the "Build" tab
Add -lfftw3 to "Other Linker Flags" (under "Linking")
Add the path to your library to the "Library Search Paths" (under "Search Paths"). In your case this will be /usr/local/lib
We use FFTW (it's great by the way), this works for us!

Did you set these options for the target?
Under "Linking->Other Linker Flags" add: "-L/path/to/library -lfftw3 -lm"

warning in /Developer/SDKs/MacOSX10.5.sdk/usr/local/lib/libfftw3.a, file is not of required architecture
Maybe the binary format was different e.g. the library could be 32 bit while the application 64.

OK - I finally got this working. I also needed the the GNU Scientific Libraries and ran into similar issues with the architecture setting. For anyone interested, this tutorial goes through how to set up Xcode and link libraries:
https://web.archive.org/web/20101006023300/http://www.boyfarrell.com/learning-curve/gnu-scientific-library-and-xcode-31

Related

exe file won't run on other devices [duplicate]

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::Blocks and setup my new libraries and includes.
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)
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.
*****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:
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 .a extension, these files include Bullet PHysics, Ogre3D, and SFML
In the search directories i have links to the MinGW/bin, and the MinGW/lib directories, along with other links to different libraries.
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.
Most of these setings are also pieces that i got from the Ogre3D Application setup tutorial if that is of any help.
If you are using MingW to compile C++ code on Windows, you may like to add the options -static-libgcc and -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.
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).
If you use MinGW then you should use the libstdc++-6.dll found into the folder of this compiler. MinGW/bin folder should be the place to search for it on your computer.
If you copy this file in the same directory as your executable, it should be OK.
Simply removing libstdc++-6.dll.a \ libstdc++.dll.a from the mingw directory fixes this.
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#
This error also occurred when I compiled with MinGW using gcc with the following options:
-lstdc++ -lm, rather than g++
I did not notice these options, and added: -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.
(I was using LINK.c rather than LINK.cpp... use make -pn | less to see what everything does!)
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).
useful to windows users who use eclipse for c/c++ but run *.exe file and get an error: "missing libstdc++6.dll"
4 ways to solve it
Eclipse ->"Project" -> "Properties" -> "C/C++ Build" -> "Settings" -> "Tool Settings" -> "MinGW C++ Linker" -> "Misscellaneous" -> "Linker flags" (add '-static' to it)
Add '{{the path where your MinGW was installed}}/bin' to current user environment variable - "Path" in Windows, then reboot eclipse, and finally recompile.
Add '{{the path where your MinGW was installed}}/bin' to Windows environment variable - "Path", then reboot eclipse, and finally recompile.
Copy the file "libstdc++-6.dll" to the path where the *.exe file is running, then rerun. (this is not a good way)
Note: the file "libstdc++-6.dll" is in the folder '{{the path where your MinGW was installed}}/bin'
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.
Project type - Cross GCC
Cross Settings
Prefix: x86_64-w64-mingw32-
Path: /usr/bin
Cross GCC Compiler
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
Cross G++ Compiler
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
Cross G++ Linker
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
I just had this issue.. I just added the MinGW\bin directory to the path environment variable, and it solved the issue.
I placed the libstdc++-6.dll file in the same folder where exe file is generated.
You only need to add your "mingw-install-directory"/bin/ to your Path in your System environment variables ... that's it !!
I had same problem. i fixed it. i was using Codeblocks and i save my .cpp file on desktop instead of saving it in Codeblocks file where MinGW is located. So i copied all dll files from MinGW>>bin folder to where my .cpp file was saved.
You can also copy the dll files in the directory of your exe file
I had this problem too. I was compiling in command prompt and used the flag -static.
My command before:
"g++ test.cpp -o test.exe"
and afterwards:
"g++ test.cpp -o test.exe -static"
I had the same problem and I solved it by running the compiled exe as an administrator.

Compile a c++ programm.exe without getting the Error: missing .dll while starting [duplicate]

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::Blocks and setup my new libraries and includes.
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)
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.
*****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:
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 .a extension, these files include Bullet PHysics, Ogre3D, and SFML
In the search directories i have links to the MinGW/bin, and the MinGW/lib directories, along with other links to different libraries.
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.
Most of these setings are also pieces that i got from the Ogre3D Application setup tutorial if that is of any help.
If you are using MingW to compile C++ code on Windows, you may like to add the options -static-libgcc and -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.
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).
If you use MinGW then you should use the libstdc++-6.dll found into the folder of this compiler. MinGW/bin folder should be the place to search for it on your computer.
If you copy this file in the same directory as your executable, it should be OK.
Simply removing libstdc++-6.dll.a \ libstdc++.dll.a from the mingw directory fixes this.
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#
This error also occurred when I compiled with MinGW using gcc with the following options:
-lstdc++ -lm, rather than g++
I did not notice these options, and added: -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.
(I was using LINK.c rather than LINK.cpp... use make -pn | less to see what everything does!)
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).
useful to windows users who use eclipse for c/c++ but run *.exe file and get an error: "missing libstdc++6.dll"
4 ways to solve it
Eclipse ->"Project" -> "Properties" -> "C/C++ Build" -> "Settings" -> "Tool Settings" -> "MinGW C++ Linker" -> "Misscellaneous" -> "Linker flags" (add '-static' to it)
Add '{{the path where your MinGW was installed}}/bin' to current user environment variable - "Path" in Windows, then reboot eclipse, and finally recompile.
Add '{{the path where your MinGW was installed}}/bin' to Windows environment variable - "Path", then reboot eclipse, and finally recompile.
Copy the file "libstdc++-6.dll" to the path where the *.exe file is running, then rerun. (this is not a good way)
Note: the file "libstdc++-6.dll" is in the folder '{{the path where your MinGW was installed}}/bin'
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.
Project type - Cross GCC
Cross Settings
Prefix: x86_64-w64-mingw32-
Path: /usr/bin
Cross GCC Compiler
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
Cross G++ Compiler
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
Cross G++ Linker
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
I just had this issue.. I just added the MinGW\bin directory to the path environment variable, and it solved the issue.
I placed the libstdc++-6.dll file in the same folder where exe file is generated.
You only need to add your "mingw-install-directory"/bin/ to your Path in your System environment variables ... that's it !!
I had same problem. i fixed it. i was using Codeblocks and i save my .cpp file on desktop instead of saving it in Codeblocks file where MinGW is located. So i copied all dll files from MinGW>>bin folder to where my .cpp file was saved.
You can also copy the dll files in the directory of your exe file
I had this problem too. I was compiling in command prompt and used the flag -static.
My command before:
"g++ test.cpp -o test.exe"
and afterwards:
"g++ test.cpp -o test.exe -static"
I had the same problem and I solved it by running the compiled exe as an administrator.

C++ windows executable compiled with Linux needs additional DLL [duplicate]

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::Blocks and setup my new libraries and includes.
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)
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.
*****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:
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 .a extension, these files include Bullet PHysics, Ogre3D, and SFML
In the search directories i have links to the MinGW/bin, and the MinGW/lib directories, along with other links to different libraries.
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.
Most of these setings are also pieces that i got from the Ogre3D Application setup tutorial if that is of any help.
If you are using MingW to compile C++ code on Windows, you may like to add the options -static-libgcc and -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.
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).
If you use MinGW then you should use the libstdc++-6.dll found into the folder of this compiler. MinGW/bin folder should be the place to search for it on your computer.
If you copy this file in the same directory as your executable, it should be OK.
Simply removing libstdc++-6.dll.a \ libstdc++.dll.a from the mingw directory fixes this.
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#
This error also occurred when I compiled with MinGW using gcc with the following options:
-lstdc++ -lm, rather than g++
I did not notice these options, and added: -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.
(I was using LINK.c rather than LINK.cpp... use make -pn | less to see what everything does!)
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).
useful to windows users who use eclipse for c/c++ but run *.exe file and get an error: "missing libstdc++6.dll"
4 ways to solve it
Eclipse ->"Project" -> "Properties" -> "C/C++ Build" -> "Settings" -> "Tool Settings" -> "MinGW C++ Linker" -> "Misscellaneous" -> "Linker flags" (add '-static' to it)
Add '{{the path where your MinGW was installed}}/bin' to current user environment variable - "Path" in Windows, then reboot eclipse, and finally recompile.
Add '{{the path where your MinGW was installed}}/bin' to Windows environment variable - "Path", then reboot eclipse, and finally recompile.
Copy the file "libstdc++-6.dll" to the path where the *.exe file is running, then rerun. (this is not a good way)
Note: the file "libstdc++-6.dll" is in the folder '{{the path where your MinGW was installed}}/bin'
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.
Project type - Cross GCC
Cross Settings
Prefix: x86_64-w64-mingw32-
Path: /usr/bin
Cross GCC Compiler
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
Cross G++ Compiler
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
Cross G++ Linker
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
I just had this issue.. I just added the MinGW\bin directory to the path environment variable, and it solved the issue.
I placed the libstdc++-6.dll file in the same folder where exe file is generated.
You only need to add your "mingw-install-directory"/bin/ to your Path in your System environment variables ... that's it !!
I had same problem. i fixed it. i was using Codeblocks and i save my .cpp file on desktop instead of saving it in Codeblocks file where MinGW is located. So i copied all dll files from MinGW>>bin folder to where my .cpp file was saved.
You can also copy the dll files in the directory of your exe file
I had this problem too. I was compiling in command prompt and used the flag -static.
My command before:
"g++ test.cpp -o test.exe"
and afterwards:
"g++ test.cpp -o test.exe -static"
I had the same problem and I solved it by running the compiled exe as an administrator.

gnu compiler from the command line

Im learning c++ and I compile from the command line. I have a problem when it comes to trying to add 3rd party libraries. I cant seam to figure out the linker system. Does anyone know a good tutorial or something like that?
For example I want to play around with the SDL2 library and ill use a command like this.
c++ -I/Library/Frameworks/SDL2.framework/Headers -L/Library/Frameworks/SDL2.framework/ -lSDL2 helloworld.cpp
and I get the error ld: library not found for -lSDL2
You need to put the linking flags last on the line:
g++ -I/Library/Frameworks/SDL2.framework/Headers helloworld.cpp -L/Library/Frameworks/SDL2.framework/ -lSDL2
I found out the answer. The following command compiled correctly. The include statement had to be changed to...
#include<SDL2/SDL.h>
and the correct compile command is...
c++ -o helloworld helloWorld.cpp -framework SDL2
I could also have used g++. On my system both c++ and g++ are symlinks to the same gnu compiler which happens to be the latest version I have installed on the system.
the option -L is a unix linker option and does not work on a MAC. The dev's for GCC were kind enough to include MAC specific linker options in the form of -framework. These serve to follow the mac tradition of how and where they like to store libraries. You can link several frameworks together by separating them with a comma. So for example i could also do -framework SDL2,SDL2_mixer as long as my source has
#include<SDL2_mixer/SDL_mixer.h>
When compiling this default search location for libraries is /Library/Frameworks. The include statement is cross platform compatable and the mac gnu linker knows that if I say
#include<SDL2/SDL.h>
that that header will be found at /Library/Frameworks/SDL2.framework/Headers
The -IPATH option still works on mac and can be used to pass alternate search locations for header and source files just like it works in unix.

libstdc++-6.dll not found

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::Blocks and setup my new libraries and includes.
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)
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.
*****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:
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 .a extension, these files include Bullet PHysics, Ogre3D, and SFML
In the search directories i have links to the MinGW/bin, and the MinGW/lib directories, along with other links to different libraries.
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.
Most of these setings are also pieces that i got from the Ogre3D Application setup tutorial if that is of any help.
If you are using MingW to compile C++ code on Windows, you may like to add the options -static-libgcc and -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.
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).
If you use MinGW then you should use the libstdc++-6.dll found into the folder of this compiler. MinGW/bin folder should be the place to search for it on your computer.
If you copy this file in the same directory as your executable, it should be OK.
Simply removing libstdc++-6.dll.a \ libstdc++.dll.a from the mingw directory fixes this.
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#
This error also occurred when I compiled with MinGW using gcc with the following options:
-lstdc++ -lm, rather than g++
I did not notice these options, and added: -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.
(I was using LINK.c rather than LINK.cpp... use make -pn | less to see what everything does!)
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).
useful to windows users who use eclipse for c/c++ but run *.exe file and get an error: "missing libstdc++6.dll"
4 ways to solve it
Eclipse ->"Project" -> "Properties" -> "C/C++ Build" -> "Settings" -> "Tool Settings" -> "MinGW C++ Linker" -> "Misscellaneous" -> "Linker flags" (add '-static' to it)
Add '{{the path where your MinGW was installed}}/bin' to current user environment variable - "Path" in Windows, then reboot eclipse, and finally recompile.
Add '{{the path where your MinGW was installed}}/bin' to Windows environment variable - "Path", then reboot eclipse, and finally recompile.
Copy the file "libstdc++-6.dll" to the path where the *.exe file is running, then rerun. (this is not a good way)
Note: the file "libstdc++-6.dll" is in the folder '{{the path where your MinGW was installed}}/bin'
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.
Project type - Cross GCC
Cross Settings
Prefix: x86_64-w64-mingw32-
Path: /usr/bin
Cross GCC Compiler
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
Cross G++ Compiler
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
Cross G++ Linker
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
I just had this issue.. I just added the MinGW\bin directory to the path environment variable, and it solved the issue.
I placed the libstdc++-6.dll file in the same folder where exe file is generated.
You only need to add your "mingw-install-directory"/bin/ to your Path in your System environment variables ... that's it !!
I had same problem. i fixed it. i was using Codeblocks and i save my .cpp file on desktop instead of saving it in Codeblocks file where MinGW is located. So i copied all dll files from MinGW>>bin folder to where my .cpp file was saved.
You can also copy the dll files in the directory of your exe file
I had this problem too. I was compiling in command prompt and used the flag -static.
My command before:
"g++ test.cpp -o test.exe"
and afterwards:
"g++ test.cpp -o test.exe -static"
I had the same problem and I solved it by running the compiled exe as an administrator.