I implement my own version based on c++ - Get path of executable - Stack Overflow
But I think the need to get executable path (cross platform) is common, because my app will find where resources are, relative to the executable path.
So, any APIs to address the issue?
ps: I think
g_get_prgname can’t address it well.
No, there is no API for it. There’s an issue open for adding a relocatability API to GLib, but nobody is working on it. You’re welcome to open a merge request.
This use case is what you’d use GResources for: embed your resources into the binary (or in an ancillary file in a well-known location, for languages that do not have the concept of embedding data into a binary), and load them automatically into the program at execution time, addressing them via special paths.
That’s not what
g_get_prgname() is for.
This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.