Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to place my configuration file independent of my application

Status
Not open for further replies.

dhingradeepti

Programmer
Mar 25, 2004
2
FR
Hello All,
I am facing one problem, we have one application which calls a shared library ,which reads one configuration file. In this configuration file log file path & some other paramaters are defined.If the config file is placed in the same directory in which the executable(i.e application) is lying, it works fine.
But as we place it in some different directory then it fails to read the configuration file.
I also tried to write the path of this configuration file in environment PATH, but that didn't work,
If anyone knows its solution then please let me know.

Thanks
 
Do you have access to the shared library code? If so, would be helpful if you post the code you use to read the configuration file.

The problem may be that the path to the file is being read relative to the execution path.

Cheers,
Dian
 
if ((envFilePtr = fopen("beEnv.txt", "r")) == NULL )
{
printf("Error in opening the file... \n");
return FAILURE ;
}

It is able to read that, if we place in the same directory as executable.
But as per our requirement we have to place it independent of executable & also we cannot give hardcoded path.
As it will be run on some diffrenet environment
 
If you tell fopen the file name quoted, it will look for it inside the current directory. You need to add the path where your configuration file will be stored but my question is:

how are you planning to tell the library where the configuration file is?

Cheers,
Dian
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top