Code Yarns ‍👨‍💻
Tech BlogPersonal Blog

How to change build output directory in Eclipse CDT

📅 2014-Jan-14 ⬩ ✍️ Ashwin Nanjappa ⬩ 🏷️ build output directory, eclipse cdt ⬩ 📚 Archive

Problem

When you build a C/C++ project in Eclipse CDT, the executable and other build files are written to Debug or Release directories, depending on the Build Configuration. For example, for a project in /home/joe/workspace/foobar, the build output directory might be /home/joe/workspace/foobar/Debug. Sometimes, you may want the build output files and executable to be placed in a specific directory in your project directory. Let us assume we want both the Debug and Release builds to put their output files in /home/joe/workspace/foobar/bin

Solution

Changing the build output directory is not simple in Eclipse CDT. A few of the complex solutions can be seen here.

As an alternative, there is a simple trick you can use: create symbolic links named Debug and Release that point to the build output directory you want:

[code lang=bash] $ cd /home/joe/workspace/foobar $ rm -rf Debug $ rm -rf Release $ mkdir bin $ ln -s bin Debug $ ln -s bin Release ```

Eclipse CDT will now think it is building to Debug or Release directories, but all those files end up in the build output directory that you wanted 😊

Tried with: Eclipse 3.7.2


© 2022 Ashwin Nanjappa • All writing under CC BY-SA license • 🐘 @codeyarns@hachyderm.io📧