1

I'm trying to run a program in cpp with the following makefile, but I haven't found a solution for the following error: "Makefile:24: *** missing separator. Stop." Does anyone have a suggestion for a solution for this?


# Makefile

# Comando padrão para compilação
CXX = g++
CXXFLAGS = -std=c++11 -Wall

# Diretórios do projeto
SRCDIR = src
INCDIR = include
OBJDIR = obj
BINDIR = bin

# Nome do executável
TARGET = $(BINDIR)/program

# Objetos gerados a partir dos arquivos de código
OBJS = $(OBJDIR)/main.o $(OBJDIR)/file1.o $(OBJDIR)/file2.o

# Comando para limpar os arquivos gerados pela compilação
RM = rm -f

# Comando padrão para compilação
$(TARGET): $(OBJS)
    $(CXX) $(CXXFLAGS) -o $(TARGET) $(OBJS)

# Regra para gerar os arquivos objeto
$(OBJDIR)/%.o: $(SRCDIR)/%.cpp
    $(CXX) $(CXXFLAGS) -I$(INCDIR) -c $< -o $@

# Comando para executar o programa
run: $(TARGET)
    ./$(TARGET)

# Comando para limpar os arquivos gerados pela compilação
clean:
    $(RM) $(OBJS) $(TARGET)

# Comando para limpar tudo e iniciar do zero
reset: clean
    $(RM) $(OBJDIR)/* $(BINDIR)/*

# Faz com que a regra "clean" seja executada mesmo que não haja alvo
.PHONY: clean reset run
user4581301
  • 33,082
  • 7
  • 33
  • 54
  • In makefiles it is ABSOLUTELY ESSENTIAL that you do not mix up your spaces and tabs. all of the instructions in the rules must be indented with tabs, not spaces. – user4581301 Apr 11 '23 at 23:21
  • Start with [makefile:4: *** missing separator. Stop](https://stackoverflow.com/q/16931770/4581301) and then see if you still have a question. – user4581301 Apr 11 '23 at 23:26

1 Answers1

1

Those are typically the errors found with Makefile files:

  1. Having spaces instead of tabs

  2. Not having a final linefeed in the file

Something Something
  • 3,999
  • 1
  • 6
  • 21
  • It's not an error to omit the final newline in a makefile. At least, not for GNU make. Maybe there are some other implementations of make where it matters. – MadScientist Apr 15 '23 at 18:58