#2207 realpath() not available in MinGW


MinGW doesn't seem to have implemented the "realpath()" function. This makes it impossible to easily compile certain software on Windows (e.g. I just failed to compile librsvg which uses the function since version 2.40.2).

There seems to have been a nearly working patch before ([patches:#256]) which was only abandoned due to seemingly minor issues.

It would be great if this can be revisited since I didn't find an alternative which would be fully portable.


Patches: #256


  • Keith Marshall

    Keith Marshall - 2014-03-29

    Welcome to the world of software porting; you need to implement those features which aren't supported natively, on the target platform.

    This is not a MinGW bug. Microsoft doesn't provide realpath(); it provides _fullpath(). ISO-C doesn't require either; nor does core POSIX -- realpath() is an XSI extension. There really is no compelling reason for MinGW to provide an implementation, and this is what led to the eventual decision to close the ticket you cite, with no intent to progress it further; it is also why I'm doing the same with this one.

    That said, the previous ticket did provide at least one -- and perhaps more than one -- plausible implementation of realpath(). You are welcome to adopt this in your own porting effort.

  • Keith Marshall

    Keith Marshall - 2014-03-29
    • status: unread --> closed
    • Type: Bug --> Feature
    • Resolution: none --> wont-fix
    • Category: Unknown --> Duplicate
  • Ede_123

    Ede_123 - 2014-03-31

    Sorry, but I'm afraid my level of programming expertise is much lower than would be necessary to create a useful implementation myself.

    Because especially you (but also others) already put some notable effort into this feature (sorry if "bug" was the wrong category) I thought it would be a real pity to waste this time spent by not further developing it.

    Since I know such features often fall into oblivion because of seemingly non-existent interest in the feature, I tried to create some obvious interest by filing a new report. I had hoped to arouse some developers interest with it, who would be willing to build upon the work done and eventually finalize the patch.

  • Keith Marshall

    Keith Marshall - 2014-03-31

    I'm not suggesting that you write your own implementation from scratch. The simple #define hack I suggested, on the earlier ticket, may be sufficient to your needs. If not, simply download one of the implementations attached to the prior ticket, compile it, and link it with your own project. That, after all, is the nub of software porting, and if your skills aren't up to that ... I almost hesitate to ask ... why are you embarking on this project at all?

    I'm sorry, but it has already been decided that adding realpath() to a core MinGW library is beyond our project scope; it is most unlikely that this decision will be revisited, given that POSIX conformity is peripheral to our mission -- to provide tools for building native Windows programs, with C99 conformity, (but not strictly POSIX) -- when the function in question isn't even required by POSIX.

  • Ede_123

    Ede_123 - 2014-03-31

    Then we misunderstood each other. I thought you were suggesting that I finalized implementation for MinGW (which is a task I'm not up to).

    Putting in the #define hack was not a problem for me and allows me to build the software for the moment but as you write yourself it's a hack after all and it neither really fixes the issues for other people nor does it really fix the problem for the project in question and it certainly does not fix the issue for other projects in general.

    I totally accept the decision not to implement the function as not really required by any standard and therefore out of project scope. I only understood the initial patch discussion slightly differently (e.g. that it was rather closed as wont-fix because of inactivity). And that would have been a shame as I wrote before.

  • Keith Marshall

    Keith Marshall - 2014-04-01

    Fixing it, for the project in question, requires users such as you, on discovering such portability issues, to push patches to the project maintainers, and for them to be receptive to them; any project striving for portability should be, especially when they insist on adopting APIs which do not conform to a widely adopted standard, (as is the case for realpath(), which limits portability to those systems which support the XSI extension to POSIX).

    To be absolutely specific on this, on Windows, Microsoft do not support POSIX, nor even C99. MinGW does strive for C99 support, but not for extensive POSIX support, (although some limited subset may be supported); XSI is strictly out of scope. This is not an issue for MinGW to resolve, but for the maintainers of the project you are trying to port.


Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:

No, thanks