As has already been pointed out; your problem is related to your programs cwd (current working directory).
There are ways on all OS's that I've worked with (except for AiX) to discover the directory where your current executable is located -so you can use that to change your working directory in your app to somewhere relative to that, so you know where to find your resources.
On Linux you can read /proc/self/exe and on Windows you can call GetModuleFileName(). OS X, FreeBSD, Solaris, and others, have similar facilities.
Also look up the functions getcwd() and chdir().