I'm working on a C++ project that uses some images. To read them inside the program I need the absolute path of this image folder. My project tree is something like:
images/ (png files)
include/ (header files)
bin/ (executable files)
src/ (source code)
Currently I'm getting the path by using the argv[0]
from main
function by I know that isn't a good way, especially when I call the executable from linux terminal (the argv[0]
show the executable name only).
I prefer a solution that work both at Linux and Windows systems. This project use CMake in Linux and Visual Studio in Windows system.