Reputation: 111
I am creating a project using mingw under windows. When run on another PC (without wingw in PATH, respectively), get errors, missing: libwinpthread-1.dll, libgcc_s_seh-1.dll, libstdc++-6.dll. How can I build the project so that everything starts up normally?
Upvotes: 1
Views: 222
Reputation: 7305
If your distributed .exe
file won't run because of missing .dll
files that's because it is linked against those files and you need to distribute these files with your .exe
file.
But actually there are 2 solutions to this problem:
.dll
files): distribute the .dll
files with your application. The best place to put the .dll
files is in the same folder as the .exe
file(s). You can use Dependency Walker to figure out which .dll
files your .exe
file needs (and which .dll
files those .dll
files need etc.) or you can use the command line tool copypedeps -r
from the pedeps project to copy your .exe
file(s) along with any .dll
files required..exe
file(s)): when building your .exe
file(s) use the --static
linker flag (and if needed also -static-libgcc
and/or -static-libstdc++
). This create a static .exe
file, which means all the static libraries are rolled into the .exe
file. This may make your .exe
quite large (though you can try reducing its size with the strip
command or the -s
linker flag) and doesn't have the advantage of .dll
files where common code is only distributed once. It may also cause longer loading times for your application, since everything is loaded at once.Upvotes: 0
Reputation: 36483
A C++ program needs runtime libraries to run. They're usually not part of the program itself! So you'd need to ship these libraries alongside with your program (which is what most software does).
You can, for many things, however, also use "static linking", which means that the parts of the libraries used by your program are included in your program itself! The -static
flag supplied to executable-generating step in your project will do that. If your program consists of but a single file, that would be g++ -o test -static test.c
(your g++
might be called x86_64-w64-mingw32-g++
or so).
Upvotes: 1