g++ stupid_program.cpp -o stupid_program.exe -std=c++17 -O2 -Wall -Wextra -Wpedantic
This does work on the Windows 10 computer which did the compiling, running from terminal (or doubleclicking the .exe) file to creates a file containing the current executing location.
However if I move this .exe file to another windows 10 computer, which did not compile it, doubleclicking the .exe file now causes an error popup to appear, teling me that the entrypoint _ZNKSt10filesystem7_cxx114path5_list13_impl_deletercIEPN"_5_ImpIE
could not be found in the DLL-library C:\PATH_TO_PROGRAM\stupid_program.exe
.
But the filesystem library does not have any .dll file, because it is part of the standard library. I know the filesystem is a recent addition to the standard ... but I did include the argument -std=c++17
and that should have taken care of that.
So is there any way I can make a program, which does use the filesystem library, work on some other Windows 10 computer than the one which compiled it?
g++ is version 9.2.0 g++.exe (MinGW.org GCC Build-2) 9.2.0
Note, there was an old bug with older MinGW with g++ version 8.xx where the filesystem library could not compile, this is not it, because that bug completely prevented compilation; this cam compile, and run, just only on the compiling computer
–
Run ntldd -R my_program.exe
to get a list of dlls your program depends on.
Look in your compiler's bin
directory, and copy any matching DLLs to the same directory as your .exe. Ignore paths reported by NTLDD, and only look at .dll filenames. Ignore any dlls not shipped with the compiler (if you don't use thirdparty libraries).
Then run it again confirm that nothing else is loaded from the compiler's bin directory.
Ship the resulting dlls with your program.
[I'm using] Latest version of mingw32
There are numerous different MinGW distributions, and the one you're using is not the best one. It ships an outdated GCC (9.x vs 12.x), and AFAIK still doesn't support multithreading.
I'd recommend MSYS2 instead.
Try with the much more recent MinGW-w64 instead of old MinGW. You can find a recent standalone version at https://winlibs.com/
MinGW-w64 can target both Windows 32-bit and 64-bit.
–
–
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.