Eclipse creating projects every time to run a single file?

前端 未结 7 1768
走了就别回头了
走了就别回头了 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 22:08

    Create a Makefile project File->New->C++ Project->Makefile project->Empty project->Linux GCC.

    Then create a Makefile for your project and add the following lines:

    CXXFLAGS := -std=c++14 -Wall -Wextra -pedantic-errors    
    
    SOURCES  := $(wildcard *.cpp)
    PROGRAMS := $(patsubst %.cpp,%,$(SOURCES))
    
    all: $(PROGRAMS)
    
    clean:
        $(RM) $(PROGRAMS)
    

    Note: the indentation of the command after clean: is using a TAB (spaces will not work).

    That will compile any source file in the project directory that ends in .cpp.

    Then select Outline View window. Select and add all and clean as targets. Then open the Build Targets window to compile or clean your project.

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