0

Code::Blocks has a "compile and run" feature which you can change the code and then click just one button and it automatically compiles the code and runs it afterwards.

How can I achieve similar behavior in Eclipse with C/C++ plugin?
I want a button (or shortcut) to 1- Automatically save any changes 2- compile 3- run

Thanks

Zeta.Investigator
  • 911
  • 2
  • 14
  • 31
  • 1
    Press the run button. Defaults are to will ask if you want to save. Set it to save and never ask again. If the file was modified, the program will then be built and run. Watch out because libraries used by the program defined in other projects will not be built. Only the program being run will be built. – user4581301 Jan 27 '16 at 20:31
  • @user4581301 you should make that an answer. – Jonah Graham Jan 27 '16 at 20:35
  • @user4581301 It doesn't have the option "never ask again" Why would I want to rebuild "libraries used by the program defined in other projects" when I've not touched them? I mean in which scenario will this caveat shows itself? – Zeta.Investigator Jan 27 '16 at 20:35
  • 2
    Never ask again may be an option I set years ago and has been carried forward for me over the last decade's worth of updates. Looks like this answer still holds under Mars: [How to enable Eclipse to autobuild/autosave changes before run (CDT)](http://stackoverflow.com/questions/23959595/how-to-enable-eclipse-to-autobuild-autosave-changes-before-run-cdt) – user4581301 Jan 27 '16 at 20:46
  • @user4581301 Thanks for the link. I should have chosen "always" for "save required dirty editors...". But about your warning, Are there any side effects to these changes? I mean when should I be wary with this config? – Zeta.Investigator Jan 27 '16 at 20:58
  • 1
    Say you have two projects open both with unsaved changes. Project 1 builds an executable. Project 2 builds a library used by Project 1. If you build Project 1, Eclipse will build Project 2, then build project 1 using the newly built and updated Project 2. If you run Project 1, Eclipse will build only Project 1 and use the old Project 2 library files. Comic hijinks ensue. – user4581301 Jan 27 '16 at 21:11
  • @user4581301 But I want to build Project 1 first,(and then 2 automatically) then run it. On the link you provided, there was a check box stating "build if necessary". Doesn't it do the trick? – Zeta.Investigator Jan 27 '16 at 21:17
  • 1
    If all you want is or have is Project 1 you're fine. The problem is when you have two interdependent projects that must both be built. – user4581301 Jan 27 '16 at 21:21

0 Answers0