I am trying to use GO with SFML and in a sample program. I need to install package gosfml using "go get".
I am on Mac OSX.
I have SFML compiled and installed SFML from source. The include files are under /usr/local/include/SFML
The following command gives the error of a header file not being found.
> go get github.com/manyminds/gosfml
# github.com/manyminds/gosfml
go-proj/src/github.com/manyminds/gosfml/circleShape.go:7:11: fatal error: 'SFML/Graphics/CircleShape.h' file not found
#include <SFML/Graphics/CircleShape.h>
^
1 error generated.
How can I configure GO to find the header file?
Thanks (new to Go)
The install is looking for header files for SFML which you do not appear to have installed. I would look here first http://www.sfml-dev.org/download/csfml/
If you are still having problems after installing the header files you might try adding an environment variable CGO_CFLAGS
with the proper include. Something like
CGO_CFLAGS="-I/path/to/installed_headers/for/sfml"
You need two environment variables set: Do that, and the error about "libs" will aslo go away.
CGO_CFLAGS == -I%CGO_SFML_INCLUDE%
CGO_LDFLAGS== -L%CGO_SFML_LIB%
I use two extra variables to hold the paths. So I also use:
CGO_SFML_INCLUDE == G:\SDK\SFML\include
CGO_SFML_LIB == G:\SDK\SFML\lib\gcc
Note that when using:
%PERCENTAGE_SIGN%
It looks up the value of the "PERCENTAGE_SIGN" environment variable and pastes the contents there.
I prefix my variables with "CGO_" not because it is required, but because it is easier to find when alphanumerically sorting environment variables.
The "CGO_" on "CGO_CFLAGS" and "CGO_LDFLAGS" IS necessary.
The linker wants the lib directory, the compiler wants the include directory
Make absolutely sure you spell everything correctly, because you won't get any different error messages if you type out something wrong here.
A big mistake I make is typing "CGO_FLAGS" instead of "CGO_CFLAGS".
Here is a video I did on setup of SFML with Golang: https://www.youtube.com/watch?v=jqoUiIsPfNA
Note that, in my answer I am using absolute paths because I find answers with less abstraction easier. Replace "G:\SDK\SFML" with wherever your sfml is.