0

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.

Vinicius Almada
  • 386
  • 3
  • 13
  • 2
    Are you familiar with https://en.cppreference.com/w/cpp/filesystem ? Helps to do most things with paths quite portably . – Öö Tiib Oct 26 '21 at 02:40
  • I assume you need `GetModuleFileNameW` for windows, as in this [answer](https://stackoverflow.com/a/55579815/4603670), you have to parse the directory path from it. – Barmak Shemirani Oct 26 '21 at 03:20

0 Answers0