I'm attempting to create a project skeleton with the following directory structure:
My current Makefile attempt contains this:
That's what I've been able to piece together from information on make from the web, however I'm running into some errors.
After I run make, currently it creates the object file in the src/ directory, and no binary files are created. I've tried solving this using the make documentation, however it isn't clear cut. I'm unsure as to why I'm receiving a permission denied error, as I should have sufficient privileges.
Thanks.
/ Makefile README /bin Binary files /src Contains source files (.cpp, .h) /build Contains the build files (.o)
My current Makefile attempt contains this:
# Project name, used to build executable NAME := skeleton # Builds list of .cpp files in src/ and src/*/ SOURCES := $(wildcard src/**/*.cpp src/*.cpp) # Builds object list from sources, substitues .cpp for .o OBJECTS := $(patsubst %.cpp,%.o,$(SOURCES)) # Directories to include for source files INCLUDE_DIRS := src CPPFLAGS +=-g -Wall -Wextra CPPFLAGS += $(foreach includedir,$(INCLUDE_DIRS),-I$(includedir)) LDFLAGS += -Lbuild .PHONY: all build clean all: $(NAME) $(NAME) : $(OBJECTS) $(LINK.cc) $(OBJECTS) -o /bin/$(NAME) build: @mkdir -p build # Makes build dir clean: rm -f /bin/$(NAME) # Just remove the binary file, not the bin directory rm -rf build # Remove the entire build directory
That's what I've been able to piece together from information on make from the web, however I'm running into some errors.
$ make g++ -g -Wall -Wextra -Isrc -Lbuild src/skeleton.o -o /bin/skelton /usr/bin/ld: cannot open output file /bin/skelton: Permission denied collect2: ld returned 1 exit status make: *** [skelton] Error 1
After I run make, currently it creates the object file in the src/ directory, and no binary files are created. I've tried solving this using the make documentation, however it isn't clear cut. I'm unsure as to why I'm receiving a permission denied error, as I should have sufficient privileges.
Thanks.