DEV Community

Discussion on: Setup Visual Studio Code for Multi-File C++ Projects

Collapse
 
jrodriguezv profile image
jrodriguez-v • Edited

I copy-pasted the Makefile content but when running make I was getting the error "mising separator. Stop".
I fixed adding a tab instead of spaces in lines 15, 16, 19 and 22:

run: clean all
[tab]clear
[tab]./$(BIN)/$(EXECUTABLE)

$(BIN)/$(EXECUTABLE): $(SRC)/*.cpp
[tab]$(CXX) $(CXX_FLAGS) -I$(INCLUDE) $^ -o $@ $(LIBRARIES)

clean:
[tab]-rm $(BIN)/*

Note: It woud be nice if the main.cpp file could be put in the root of the project folder, outside of src.

Great post by the way. I spent hours trying to compile in VS Code a multi file project before I seeing this.
Thanks!.

Collapse
 
talhabalaj profile image
Talha Balaj

I'm glad you found a work-around, I copy-pasted the makefile from my project, so maybe tabs were removed.

If you want main.cpp in your root directory of your project. try this.

$(BIN)/$(EXECUTABLE): $(SRC)/*.cpp main.cpp
Enter fullscreen mode Exit fullscreen mode

Thank you, I'm glad it helped.