Question

I'm using Eclipse as an IDE for C++ programming. On my system I have a network home directory and a data partition. I want the project stored in the home directory (which gets backed up by our admin), but the calculations should be done on the data partition. How can I do that?

I've already figured out how to change the build location under build artifacts, but the files I generate in my C++ code (e.g. fstream f; f.open("filename");) are stored in the project directory in my home folder.

One possibility is to build from Eclipse and then run the binary from the console. But that's not as nice as just clicking on Run.

I hope someone can help me.

Was it helpful?

Solution

You need to find something that is called "Working Dir/Path" or similar. (No idea what the name is in Eclipse)

Note however that this can also affect how dynamic libraries are loaded.

The other option is to have a config option in your Program and have your code handle the setting of the paths along the lines of (untested! treat as Pseudocode!)

f.open((path / filename).c_str());             // using boost::filesystem 
f.open((path + PATH_SEP + filename).c_str());  // using std::string 

OTHER TIPS

You are opening the files in the current working directory. You can either use absolute paths when specifying file name or you can do a chdir before creating/opening files. You should also avoid hardcoding file names in code. Instead, you can specify file names using config files, environment variables, command line arguments, etc. Note that you can also specify additional command line arguments in Eclipse to be passed to your executable when debugging.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top