Hi i have problems installing SDL2 for golang (using Visual Studio Code)
try to get the package:
"C:\Users\Bob\go\src\flappyGopher>go get -v github.com/veandco/go-sdl2/sdl
github.com/veandco/go-sdl2/sdl
# github.com/veandco/go-sdl2/sdl
In file included from ..\github.com\veandco\go-sdl2\sdl\audio.go:4:0:
./sdl_wrapper.h:2:23: fatal error: SDL2/SDL.h: No such file or directory
compilation terminated."
I used this manual: https://github.com/vinzBad/go-sdl2-tut/blob/master/00_preparation/windows.md
I have also the env variables:
CGO_CFLAGS C:\MinGW64\mingw64\include
GOPATH C:\Users\Bob\go
GOROOT C:\Go\
PATH ... C:\MinGW64\mingw64\x86_64-w64-mingw32\bin;C:\MinGW64\mingw64\bin;C:\Users\Bob\Downloads\SDL2-2.0.8\x86_64-w64-mingw32\include\SDL2
edit:the gcc output looks like a mess
C:\Users\Bob>gcc -xc -E -v -
Using built-in specs.
COLLECT_GCC=gcc
Target: x86_64-w64-mingw32
Configured with: ../../../src/gcc-5.1.0/configure --build=x86_64-w64- mingw32 --e
nable-targets=all --enable-languages=ada,c,c++,fortran,lto,objc,obj-c++ --enable
-libgomp --enable-lto --enable-graphite --enable-cxx-flags=-DWINPTHREAD_STATIC -
-disable-build-with-cxx --disable-build-poststage1-with-cxx --enable-libstdcxx-d
ebug --enable-threads=posix --enable-version-specific-runtime-libs --enable-full
y-dynamic-string --enable-libstdcxx-threads --enable-libstdcxx-time --with-gnu-l
d --disable-werror --disable-nls --disable-win32-registry --prefix=/mingw64tdm -
-with-local-prefix=/mingw64tdm --with-pkgversion=tdm64-1 --with-bugurl=http://td
m-gcc.tdragon.net/bugs
Thread model: posix
gcc version 5.1.0 (tdm64-1)
COLLECT_GCC_OPTIONS='-E' '-v' '-mtune=generic' '-march=x86-64'
C:/Program Files/TDM-GCC-64/bin/../libexec/gcc/x86_64-w64-mingw32/5.1.0/cc1.exe
-E -quiet -v -iprefix C:/Program Files/TDM-GCC-64/bin/../lib/gcc/x86_64-w64-min
gw32/5.1.0/ -D_REENTRANT - -mtune=generic -march=x86-64
ignoring duplicate directory "C:/Program Files/TDM-GCC-64/lib/gcc/../../lib/gcc/
x86_64-w64-mingw32/5.1.0/include"
ignoring duplicate directory "C:/Program Files/TDM-GCC-64/lib/gcc/../../lib/gcc/
x86_64-w64-mingw32/5.1.0/../../../../include"
ignoring duplicate directory "C:/Program Files/TDM-GCC-64/lib/gcc/../../lib/gcc/
x86_64-w64-mingw32/5.1.0/include-fixed"
ignoring duplicate directory "C:/Program Files/TDM-GCC-64/lib/gcc/../../lib/gcc/
x86_64-w64-mingw32/5.1.0/../../../../x86_64-w64-mingw32/include"
#include "..." search starts here:
#include <...> search starts here:
C:/Program Files/TDM-GCC-64/bin/../lib/gcc/x86_64-w64-mingw32/5.1.0/include
C:/Program Files/TDM-GCC-64/bin/../lib/gcc/x86_64-w64-mingw32/5.1.0/../../../..
/include
C:/Program Files/TDM-GCC-64/bin/../lib/gcc/x86_64-w64-mingw32/5.1.0/include-fixed
C:/Program Files/TDM-GCC-64/bin/../lib/gcc/x86_64-w64-mingw32/5.1.0/../../../..
/x86_64-w64-mingw32/include
End of search list.
Please see this.
The reason is go install
tried to compile some cgo
code of the github.com\veandco\go-sdl2
package, and that code apparently wants to use the C header files of the libsdl2
library¹.
You need to make libsdl2
available to the compiler.
To figure out where the C compiler expects to find the include (header) files, see this.
¹ That's how C works. To use a compiled library in other C code, the compiler usually needs to know the definitions of the types and functions provided by that library. The formats of such libraries—contrary to Go libraries—do not typically embed type information in their metadata, so the compiler needs to get that information from somewhere. In C and C++ world this information is commonly kept in the so-called include (also: header) files which are included—through the use of a so-called preprocessor—both into the code used to build a library and the code which uses the library.