This is a creation in Article, where the information may have evolved or changed.
- sdl2.0 Golang Binding I am using this, but it's official introduction only Linux and OSX system instructions, no windows, in my MBP after the set up to consider in win also set up a development environment, so it can be more convenient cross-platform.
- The steps are as follows:
- To configure the go environment, you can refer to the official documentation or here.
Go get the above mentioned library, but repeatedly prompt the following error:
Cc1.exe:sorry, Unimplemented:64-bit mode not compiled in
Later found that as long as the use of CGO will be reported this error, because I downloaded the Go 1.3.2 64-bit version, but the local GCC is 32-bit. Toss for a long time did not solve, has not been able to download to 64-bit MinGW, the official download is half of the time to download the error, even if the agent is hung on the sf.net, later found a good-hearted person to do the offline download package, and then add GCC to the PATH environment variable , I can only use the CGO.
- To this again build go-sdl words, will be prompted to find sdl2/sdl.h file, this problem is more toss,
Google for a long time no one to give a concrete solution, did not mention CGO compile, the corresponding C file needs to be placed under what directory. Perhaps too simple to mention it, but for the novice is a more troublesome thing. Some people say that they can solve the source code, it is true, but please clarify the primary purpose: To learn to use Golang to develop the SDL program.
At first I was trying to put SDL's header file into the GITHUB.COM/VEANDCO/GO-SDL2/SDL directory,
Because there are already some C files in the directory, so consider CGO will search the current directory, the result has failed, it can only search the current directory, once placed in a subdirectory is not. Next try to use absolute path, still fail, not clear for. Then came to think that CGO was compiled C code through GCC, so the official SDL download binary package (MinGW version) extracted into the GCC directory (SDL official MinGW package should contain bin,include,lib,share these directories, Simply place them in the GCC root directory and overwrite them with the same name directory)
Then go build, everything OK
At this point, the whole environment should be done, let ' go