Code Yarns ‍👨‍💻
Tech BlogPersonal Blog

How to change working directory in Eclipse CDT

📅 2013-Sep-22 ⬩ ✍️ Ashwin Nanjappa ⬩ 🏷️ eclipse, eclipse cdt, working directory ⬩ 📚 Archive

Eclipse CDT is a C/C++ development environment for Eclipse. When you compile a binary in a CDT project and run it, it runs with the root directory of the project as its working directory. This is the directory where the program would read or write files if you provide no path or directories to it.

If you wish that the program run with a different directory as its working directory, here is how:

  1. Right-click on the project name in Project Explorer, choose Properties > Run/Debug Settings > Choose the launch configuration > Edit > Arguments > Working directory

  2. Uncheck the Use default option. For a project named foobar, the default entry here is ${workspace_loc:foobar}

  3. If the working directory you want is a subdirectory of the project directory, then append it. For example: ${workspace_loc:foobar}/bin. Else type in an absolute path as working directory.

Tried with: Eclipse 3.7.2, Eclipse CDT 8.0.2 and Ubuntu 12.04 LTS