Basically im trying to build a game engine with OpenGl and SDL. Im using a makefile to compile it but I get an error. The error started appearing after I reorganized my folder structure and I included the src folder to the include path so i can access them with the absolute path. For example Renderer/Camera.h
instead of ../Renderer/Camera.h
.
When I try to compile my project I get this error:
C:/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: cannot find src: Permission denied
collect2.exe: error: ld returned 1 exit status
mingw32-make: *** [Makefile:57: build] Error 1
This is my makefile
RELEASE_MACRO:=-D RELEASE
DEBUG_MACRO:=-D DEBUG
OS_MACRO:=-D
BIN := bin
SRC := src
INCLUDE := -Isrc -Iinclude
LIB := lib
#Check the OS
ifeq ($(OS),Windows_NT)
# the compiler: gcc for C program, define as g for C
CC := g
# The windows command for delete
DEL := del
# The windows slash for directory
SLASH := \
# Indicating that we dont need wine, unlike in linux
WINE :=
OS_MACRO =__WINDOWS__
SOURCES := $(wildcard $(SRC)/***/*.cpp) $(wildcard $(INCLUDE)/***/*.cpp) $(wildcard $(SRC))
else
# CURRENTLY NOT WORKING
# Linux compiler for windows executables (64 bits)
CC := x86_64-w64-mingw32-g
# Linux command for delete (rm -f)
DEL := $(RM)
# Linux slash for directory
SLASH := '/'
# Wine, program for executing windows apps .exe
WINE := wine
OS_MACRO =__LINUX__
SOURCES := $(shell dir . -r *.cpp)
endif
# compiler flags:
# -g adds debugging information to the executable file
# -Wall turns on most, but not all, compiler warnings
CFLAGS:= -g -Wall
# libraries to link to the project
LIBRARIES := -lmingw32 -lSDL2main -lSDL2 -lSDL2_net -lSDL2_mixer -lmingw32 -lopengl32 -lglew32 -lglu32 -lSDL2main -lSDL2 -lSDL2_image
# the build target executable
EXECUTABLE := game
all: build
showfiles:
@echo $(SOURCES)
# Builds the executable game
build:
echo "Building..."
$(CC) $(CFLAGS) $(INCLUDE) -L $(LIB) $(OS_MACRO) $(DEBUG_MACRO) -o $(BIN)/$(EXECUTABLE) $(SOURCES) $(LIBRARIES)
# Run the game
run:
@echo "Executing..."
$(WINE) $(BIN)/$(EXECUTABLE)
# Build then run the game
build-and-run: clean build run
# Remove the executable
clean:
@echo "Clearing..."
$(DEL) bin$(SLASH)$(EXECUTABLE).exe
This is my project folder structure
CodePudding user response:
This is not valid:
SOURCES := $(wildcard $(SRC)/***/*.cpp) $(wildcard $(INCLUDE)/***/*.cpp) $(wildcard $(SRC))
I don't know where you got that wildcard syntax from but it doesn't do what you think it does. ***
is identical to *
in standard glob syntax which is what GNU make uses. Also do you really expect to find .cpp
files in your $(INCLUDE)
directory? That would be very strange.
The problem, as ssbssa points to, is that $(wildcard $(SRC))
will expand to $(wildcard src)
which is just src
, so you're trying to add a directory to your link line which is illegal and the linker complains.