Makefile: multiple definition and undefined reference error

后端 未结 3 638
生来不讨喜
生来不讨喜 2021-01-24 01:35

Im currently learning how to code without an IDE and so Im learning how to write makefiles. Here is my current test-project:

\\__ /CoDstructor/
      |\\__ Makef         


        
3条回答
  •  悲&欢浪女
    2021-01-24 02:03

    Your $(OBJS): $(SOURCES) rule is not what you think it is. As a result, you're building both main.o and types.o from the same main.cpp file ($< param in command line). Hence you have two identical files which are conflicting, while types.cpp wasn't even built.

    Correct rule would be $(OBJ_DIR)/%.o: $(SRC_DIR)/%.cpp

提交回复
热议问题