【问题标题】:Recipe commences before first target. Stop. While running a makefile配方在第一个目标之前开始。停止。运行生成文件时
【发布时间】:2018-01-21 04:19:05
【问题描述】:

我已经在这个 makefile 上工作了几个小时,但我只是不知道我做错了什么。我正在尝试制作六个不同的可执行文件(Q1-Q6),但我不断收到上面提到的错误。这是我的代码

BUILD_FLAGS= -W -Wall -pedantic
CC=g++
RM=rm
EXES=*.exe
OBJECTS=*.o
g++ -c Question1.cpp
g++ -c Question2.cpp
g++ -c Question3.cpp
g++ -c Question4.cpp
g++ -c Question5.cpp
g++ -c Question6.cpp
g++ -o Question1.exe Question1.o
g++ -o Question2.exe Question2.o
g++ -o Question3.exe Question3.o
g++ -o Question4.exe Question4.o
g++ -o Question5.exe Question5.o
g++ -o Question6.exe Question6.o

clean:
     $(RM)$(EXES)$(OBJECTS)

【问题讨论】:

    标签: c++ makefile g++ executable


    【解决方案1】:

    尝试如下。

    BUILD_FLAGS=-W -Wall -pedantic
    CC=g++
    RM=rm
    EXES=*.exe
    OBJECTS=*.o
    
    all: Question1.exe Question2.exe Question3.exe Question4.exe Question5.exe Question6.exe
    
    %.exe: %.cpp
        g++ ${BUILD_FLAGS} -o $@ $<
    
    clean:
       $(RM) $(EXES)
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2011-02-24
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多