Home > Net >  c 17 std::filesystem can not run on other (windows 10) computer
c 17 std::filesystem can not run on other (windows 10) computer

Time:07-16

I have a program, compiled using MinGW on and for windows 10, I want this program to run on other peoples computers, even if they do not have MinGW or any c compilers installed.

Normally, this is easy.

I just include the exe file and the dll files for any third party libraries, and it does indeed work ... unless I use one particular c standard library, the <filesystem> library from c 17, in which case my program can only run on the computer which did the compiling.

For example, this program only prints what file it is currently in to a file.

#include<fstream>
#include<filesystem>

using namespace std;
int main(int argc, char* argv[])
{
    ofstream OUT("location.txt");
    OUT<<filesystem::current_path()<<endl;
    OUT.close();
    return 0;
}

I compile it with mingw32 as such:

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

CodePudding user response:

Try with the much more recent MinGW-w64 instead of old MinGW. You can find a recent standalone version at https://winlibs.com/

CodePudding user response:

Did you check that the

libstdc  -6.dll

Is available or the relevant libraries are statically included static linked libs

  • Related