You are using a relative path to cwd
but you need to use either a relative path based on the location of the program binary or an absolute path based on the filesystem's root like /usr/lib/yourprogram/assets
.
If you want to build a relative path based on the location of the binary, which might be more flexible in some situations, then you should use dirname()
. Like this:
char *my_location = dirname(argv[0]); // argv[0] contains the path to the binary
Check man 3 dirname
for more info.