Eclipse creating projects every time to run a single file?

前端 未结 7 1765
走了就别回头了
走了就别回头了 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:42

    I know eclipse has the ability to create a java scrap book, using this you can write a bit of java code and just run that code, with out having to setup any classes or main functions. You might want to look to see if eclipse has C++ scrap book in the New dialog box.

    0 讨论(0)
  • 2021-02-13 21:46

    Eclipse is great. I love it, but you are right, there is too much burden with one-file projects. So maybe approach problem in different way:

    1. Write code in Eclipse enjoying all IDE features.

      Put all your one-file programs to single project. No, Eclipse won't compile them because of multiple main functions but...

    2. Compile file from command line.

      You can copy proper command line from Eclipse console when building project. You must be smart because you are playing topcoder so you figure out how to alter command line for your need. ;)

    0 讨论(0)
  • 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...

    0 讨论(0)
  • 2021-02-13 21:58

    Use geany. It works out of the box with single C++ file. And it can run a custom make file if you need to modify your setting.

    0 讨论(0)
  • 2021-02-13 22:01

    Create a new Folder (ex: tmplib)

    Right click on "tmplib" -> Resource Configuration -> Exclude from build (debug and release)

    Drag/drop files between src and "tmplib" folder - anything in src folder will be built (no need to delete src folder)

    0 讨论(0)
  • 2021-02-13 22:05

    That's what I do. You can create a project called Coeforces for example, then you can create a folder inside the project called AC for example and right click on it --> Resource Configuration --> Exclude from build --> check both Debug and Release .

    Then delete src folder. Whenever you finish a code just drag and drop it in the folder and then you can create a new source file directly in the project . Also you can create another folder called WA for example for problems that you couldn't solve and want to save the code in order to think again later.

    0 讨论(0)
提交回复
热议问题