SFML community forums
Help => General => Topic started by: Gabertho on June 23, 2021, 10:32:59 pm
-
Hey guys, I'm having some trouble with the release of my game in the Windows OS. I have this makefile code:
CXX := g++
CXX_FLAGS := -Wall -Wextra -Wno-unused-parameter -std=c++17 -ggdb
BIN := bin
SRC := src
INCLUDE := include
LIB := lib
LIBRARIES := -lsfml-graphics -lsfml-audio -lsfml-window -lsfml-system
EXECUTABLE := main
MKDIR_P = mkdir -p
.PHONY: directories
all: directories $(BIN)/$(EXECUTABLE)
directories: ${BIN}
${BIN}:
${MKDIR_P} ${BIN}
run: clean all
clear
./$(BIN)/$(EXECUTABLE)
$(BIN)/$(EXECUTABLE): $(SRC)/*.cpp
$(CXX) $(CXX_FLAGS) -I$(INCLUDE) -L$(LIB) $^ -o $@ $(LIBRARIES)
clean:
-rm $(BIN)/*
So, when I'm in the VSCode IDE and I type make and then bin/main.exe, the game open and everything works properly. But, when I enter the game paste and try to open the game by clicking the main.exe file, it shows a error message as if the dlls couldn't be found. I can't figure out why this, since I can open the game in the terminal but not clicking the .exe file.
-
I don't use VSCode for C++, so just guessing here, but if you needed to type bin/main.exe instead of main.exe then the working directory for VSCode isn't the bin directory.
When you run an exe from explorer, the working directory is the directory where the exe is.
All of the sfml dlls need to be in either the system path or the working directory (ie. bin if running from explorer).
-
Actually, they should be in the same directory as your executable and not the working directory.
I assume in VS Code they end up in the build folder, while when you run it yourself they aren't there.
You simply have to copy the DLLs next to your exe.