gpt4 book ai didi

How to fix interop errors in Go?(如何修复围棋中的互操作错误?)

转载 作者:bug小助手 更新时间:2023-10-24 20:08:54 29 4
gpt4 key购买 nike



I'm trying to install SDL2 mapping for Go (https://github.com/veandco/go-sdl2). However, when I build the application, the following error happened :

我正在尝试安装Go(https://github.com/veandco/go-sdl2).)的SDL2映射但是,当我构建应用程序时,发生了以下错误:


# github.com/veandco/go-sdl2/sdl
In file included from D:\Go\pkg\mod\github.com\veandco\[email protected]\sdl\audio.go:4:
./sdl_wrapper.h:2:18: fatal error: SDL2/SDL.h: No such file or directory
2 | #include <SDL2/SDL.h>
| ^~~~~~~~~~~~
compilation terminated.


  • GOPATH = D:\Go

  • Go tools = D:\Go\bin (in user PATH)

  • Go installation folder = D:\Languages\Go\bin (in system PATH)

  • MingW / MSYS2 path = D:\MSYS2 (in system PATH)

  • SDL2 DLL path = D:\MSYS2\mingw64\bin (in system PATH)

  • gcc/g++ path = D:\MSYS2\ucrt64\bin (in system PATH)

  • SDL2 for MingW64 = package


// main file under ./application/main.go
package main

import "github.com/veandco/go-sdl2/sdl"

func main() {
err := sdl.Init(sdl.INIT_EVERYTHING)
if err != nil {
return
}
}


// go.mod
module go-test-project

go 1.21

require github.com/veandco/go-sdl2 v0.4.35

# Makefile to compile
.DEFAULT_GOAL := build

build:
go build -o ./target/app.exe go-test-project/application
./target/app.exe

I previously had a library binding error, but I had forget to add the SDL2 DLL path.
I'm on Windows 11 with a fresh install of Go and a fresh install of Windows

我之前有一个库绑定错误,但我忘记添加SDL2DLL路径。我在Windows 11上安装了全新的Go和全新的Windows


To be honest, I'm lost. It's my first time attempting to use a library in Go that use interop (use C function if you prefer). In the past, I used SDL2 in c++, so I expected the linking process to go kind of smothly, but it didn't. Knowing this is the only c++ library that I ever used too, I don't have a lot of experience in installing library.

老实说,我迷路了。这是我第一次尝试在围棋中使用使用互操作的库(如果您愿意的话,可以使用C函数)。过去,我在c++中使用SDL2,所以我希望链接过程会比较顺利,但事实并非如此。知道这是我唯一使用过的C++库,我在安装库方面没有太多经验。


EDIT 1 : Add bullet points

编辑1:添加项目符号


更多回答
优秀答案推荐
更多回答

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com