At 2/2/2009 02:33 AM, you wrote: >Hi All, >I have a executable file at a particular location in the filesystem. From >root directory i run this exe. This exe will load a shared object from >another location (say /usr/lib). Now the shared object wants to read a >config file which is in the directory where the exe is located. How can it >get that path. > >Remember we are running the exe from the home directory and exe can be >located in /usr/bin directory. Now the shared objected which is loaded by >this exe needs the path /usr/bin . It is not the PWD(present working >directory). > >Please help. > >TIA
If I understand you correctly, you run the program from the root directory thusly: /somedirectory/someother directory/myprogram If that is correct, then argv[0] will contain the complete path to the program, i.e. /somedirectory/someother directory/myprogram If you strip off the program name, you will have the path to where the program resides. So you get your config file from /somedirectory/someother directory/myconfigfile ~Rick
