I'm struggling to create a working make file.
My structure
- root/Makefile
- root/src/main.cpp
- root/include/
My code
# Define compiler
CC = g++
# Compiler flags
CFLAGS = -g -Wall
# Build target executable
DIR = /src
INCLUDES = ../include
TARGET = main
all: $(TARGET)
$(TARGET): $(TARGET).cpp
cd $(DIR) &
$(CC) $(CFLAGS) -I $(INCLUDES) -o $(TARGET) $(TARGET).cpp
clean:
cd $(DIR) &
$(RM) $(TARGET)
My Error
make: *** No rule to make target main.cpp', needed by
main'. Stop.
EDIT
Inside my main.cpp I have this line at the top which is meant to be found by my Makefile: #include "pugixml.hpp"
$(TARGET): src/$(TARGET).cpp
– mpromonetcd /src & g++ -g -Wall -I ../include -o main main.cpp /bin/sh: line 0: cd: /src: No such file or directory clang: error: no such file or directory: 'main.cpp' clang: error: no input files make: *** [main] Error 1
– JimmyDIR = /src
=> this is an absolute path to which you are trying tocd
– Peter UhnakDIR = src
– Jimmy