0

I have this C++ program in Clion, however, I need to create a makefile for it to be run on text editors and not IDEs, it is for a university, they do not use IDEs.

When I run my program trough the run button on CLion, it works perfectly but when I run it trough the makefile, it displays multiple errors that don't even make sense.

When is the issue occurring from? Please tell me if you need more information or images.

Project structure:

Project structure

Errors with makefile:

Errors with makefile

Run without the makefile:

Run without the makefile

Makefile:

OBJS    = main.o HastTable.o Book.o
SOURCE  = main.cpp HastTable.cpp Book.cpp
HEADER  = HashTable.h Book.h
OUT = book
CC   = g++
FLAGS    = -g -c -Wall -Wextra

all: $(OBJS)
    $(CC) -g $(OBJS) -o $(OUT) $(LFLAGS)

main.o: main.cpp
    $(CC) $(FLAGS) main.cpp

HastTable.o: HastTable.cpp
    $(CC) $(FLAGS) HastTable.cpp

Book.o: Book.cpp
    $(CC) $(FLAGS) Book.cpp


clean:
    rm -f $(OBJS) $(OUT)
Zoso
  • 3,273
  • 1
  • 16
  • 27
  • 1
    Try adding `-std=c++1z` to you `FLAGS`. It seems the Makefile route doesn't recognize braced list initlalization. – Zoso Apr 14 '21 at 05:01
  • Yes, thank you, that worked, I need to pass an command line argument to the makefile and could not find a viable solution to it, can you help? – DimitarIvanov Apr 14 '21 at 06:14
  • Can you give an example of what argument you need to pass and to which program this argument needs to be passed? If it's unrelated to this question, you could create a separate question. – Zoso Apr 14 '21 at 07:10
  • @Zoso I need to pass a file name which will be a string to main.cpp – DimitarIvanov Apr 14 '21 at 17:34
  • Do the answers [here](https://stackoverflow.com/questions/2826029/passing-additional-variables-from-command-line-to-make) help you? – Zoso Apr 15 '21 at 07:16

0 Answers0