Telroshan / go-sfml

Up-to-date Go bindings for SFML, the Simple and Fast Multimedia Library.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Please open wiki for documentation

TheFern2 opened this issue · comments

I would like to contribute by adding steps needed to run on Windows 10 using mingw64. Can you open wiki for community contributions?

Here is the guide, also thanks to @DennisPing I copied some of the choco and mingw stuff over to my guide. My guide on a gist here

Guide for using sfml on windows with golang

Credit to https://github.com/DennisPing/Windows-10-Cpp-MinGW64

Initial installs and setup

Run powershell as admin

Prequisites

Restart powershell as admin

choco install mingw cmake make

Add cmake to path C:\Program Files\CMake\bin

In powershell check versions:

g++ --version
>>  g++.exe (MinGW-W64 x86_64-posix-seh, built by Brecht Sanders) 11.2.0
    Copyright (C) 2021 Free Software Foundation, Inc.

cmake --version
>>  cmake version 3.21.3

make --version
>>  GNU Make 4.3
    Built for Windows32

Download sfml and csfml 2.4 (Currently go-sfml bindings are compatible with 2.4)

Extract them to where you normally put your libraries, I put mine on D:\libs\x64

Env variables

Add the following env variables to system, change path accordingly on first two, also note I renamed mine to CSFML-2.4, instead of CSFML:
Key : Value

CGO_SFML_INCLUDE D:\libs\x64\CSFML-2.4\include
CGO_SFML_LIB D:\libs\x64\CSFML-2.4\lib\gcc
CGO_CFLAGS -I%CGO_SFML_INCLUDE%
CGO_LDFLAGS -L%CGO_SFML_LIB%
CGO_ENABLED 1

CSFML DLLs

Copy csfml from CSFML-2.4\bin to where your main.exe compiled, normally you only need the dlls you're importing.

Build and Run

NB: In powershell

go build .
go run .

Hello @TheFern2 ! Just picked up the ownership of this repo.

Closing this issue since all that information is now in the repo's README.

Things I noticed :

  • You don't actually need to have either cmake or make installed on Windows to be able to build an app using the go bindings, you only need gcc
  • CGO_ENABLED should be set to 1 by default on Windows as specified in the doc, so you shoudn't need to set it to 1 in that case. I added a mention for it in the README, in case the associated error appears when trying to build.
  • You don't need to download the SFML lib, only CSFML actually, the only thing that's missing from CSFML is the openal32.dll file that you may find in SFML's bin folder, think I'll add a mention for that too, since I currently only refer to it in the tennis example