Programs using std::filesystem with gcc 9.2.0 fail to run

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Programs using std::filesystem with gcc 9.2.0 fail to run

velix
It's possible to compile and link programs that use std::filesystem with
the g++ 9.2.0 compiler for Cygwin.  For instance if I place the following
program into a file name "x.cpp":

    #include <iostream>
    #include <filesystem>

    int main()
    {
        std::filesystem::path p{"/tmp"};
        std::cout << p << std::endl;
    }

Then compile with:

    g++ -std=c++2a -Wall -O3 x.cpp

It builds successfully.  But running the output "a.exe" file exits
immediately with exit code 127.  It does not help if I also add
"-lstdc++fs" to the build command.

The output of "uname -a" is:
    CYGWIN_NT-6.1 price1 3.1.2(0.340/5/3) 2019-12-21 15:25 x86_64 Cygwin



--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple

Reply | Threaded
Open this post in threaded view
|

Re: Programs using std::filesystem with gcc 9.2.0 fail to run

Csaba Ráduly
On Sat, Feb 8, 2020 at 2:22 AM <[hidden email]> wrote:

> It's possible to compile and link programs that use std::filesystem with
> the g++ 9.2.0 compiler for Cygwin.  For instance if I place the following
> program into a file name "x.cpp":
>
>     #include <iostream>
>     #include <filesystem>
>
>     int main()
>     {
>         std::filesystem::path p{"/tmp"};
>         std::cout << p << std::endl;
>     }
>
> Then compile with:
>
>     g++ -std=c++2a -Wall -O3 x.cpp
>
> It builds successfully.  But running the output "a.exe" file exits
> immediately with exit code 127.  It does not help if I also add
> "-lstdc++fs" to the build command.
>

Works just fine wih me:

$ g++ -std=c++2a -Wall -O3 fsys.cpp
$ ./a.exe
"/tmp"

Try running yours under gdb. You may get some more useful information about
the error.
Csaba
--
You can get very substantial performance improvements
by not doing the right thing. - Scott Meyers, An Effective C++11/14 Sampler
So if you're looking for a completely portable, 100% standards-conformant
way
to get the wrong information: this is what you want. - Scott Meyers
(C++TDaWYK)

--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple