使用makefile编译错误:

时间:2018-02-09 20:58:58

标签: c++ makefile

我在makefile中遇到以下错误:

/ usr / lib / gcc / x86_64-linux-gnu / 5 /../../../ x86_64-linux-gnu / crt1.o:在函数_start': (.text+0x20): undefined reference to main' collect2:错误:ld返回1退出状态 makefile:7:目标' runme'失败 make:*** [runme]错误1

那是我的makefile代码:

CXXFLAGS+=-std=c++11
OBJ=main.o Shape.o
all: runme
runme: main.o Shape.o
    g++ $(OBJ) $(CXXFLAGS) -o runme
main.o: main.cpp Shape.hpp
    g++ $(CXXFLAGS) main.cpp -o main.o
Shape.o: Shape.hpp Shape.cpp
    g++ $(CXXFLAGS) Shape.cpp -o Shape.o
clean: 
    rm -f *.o
distclean: clean
    rm -f runme

0 个答案:

没有答案