Search code examples
c++eclipseoutput-directory

C++ file output directory in Eclipse


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.


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