Eclipse creating projects every time to run a single file?

前端 未结 7 1763
走了就别回头了
走了就别回头了 2021-02-13 21:03

i am a beginner using eclipse CDT. usually in DEVc++ or other lightweight IDE\'s we can directly open and edit a single .cpp file from desktop and run it.

on the other h

7条回答
  •  情歌与酒
    2021-02-13 21:57

    Assuming you dropped several .cpp files in the same project (containing a main in each), you can :

    • Right-click on your .cpp file and Properties > C/C++ build > Settings > Manage Configurations.
    • Create a new configuration and set it as the active one + OK.
    • Select the newly created configuration.
    • Select the files you don't want to run for this configuration, open Properties and check "exclude resource form build", for each one.
    • Select the file(s) you want to keep for that configuration and make sure "exclude resource form build" is unchecked.
    • Build the Project
    • Press button play

    Finally, to switch from one run configuration to another, go to Project > Properties > Manage Configurations and change the active one. Rebuild and run.

    EDIT: as shivi mentioned, the most painful part (excluding resources form build) can be done in one single shot by multi-selecting the files to exclude in the Package Explorer view and Right-click > Resource Configurations > Exclude from build....

    That's the best we can do...

提交回复
热议问题