make: implicit rule to link c++ project

后端 未结 7 1039
礼貌的吻别
礼貌的吻别 2020-12-31 04:52

I am working my way through a make tutorial. Very simple test projects I am trying to build has only 3 files: ./src/main.cpp ./src/implementation.cpp and

7条回答
  •  甜味超标
    2020-12-31 05:17

    Hmm...

    CXX = g++               # Just an example
    CXXFLAGS = -Wall -O2    # Just an example
    
    prog: main.o implementation.o
        $(CXX) $(CXXFLAGS) $^ -o $@
    
    main.o: header.hpp
    implementation.o: header.hpp
    

    should do the job. Why your variant isn't working is explained in Konrad Rudolph answer

提交回复
热议问题