Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: error generating makefile .exe file  (Read 2686 times)

0 Members and 1 Guest are viewing this topic.

Gabertho

  • Newbie
  • *
  • Posts: 1
    • View Profile
error generating makefile .exe file
« 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.

kojack

  • Sr. Member
  • ****
  • Posts: 343
  • C++/C# game dev teacher.
    • View Profile
Re: error generating makefile .exe file
« Reply #1 on: June 23, 2021, 11:17:49 pm »
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).

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11034
    • View Profile
    • development blog
    • Email
Re: error generating makefile .exe file
« Reply #2 on: June 24, 2021, 01:00:31 pm »
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.
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/