Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

自定义 LibName 不支持 go1.21.1 以上版本 #201

Closed
funte opened this issue May 13, 2024 · 5 comments
Closed

自定义 LibName 不支持 go1.21.1 以上版本 #201

funte opened this issue May 13, 2024 · 5 comments

Comments

@funte
Copy link

funte commented May 13, 2024

环境 vscode, win11 22h2.

命令 go run . 报错:

panic: The specified module could not be found.

goroutine 1 [running]:
github.com/ying32/govcl/vcl/api.loadUILib()
        xxx/gopath-1.21.1-x64/pkg/mod/github.com/ying32/[email protected]+incompatible/vcl/api/dylib.go:43 +0xa5
github.com/ying32/govcl/vcl/api.init()
        xxx/gopath-1.21.1-x64/pkg/mod/github.com/ying32/[email protected]+incompatible/vcl/api/dylib.go:23 +0x15e
exit status 2

命令 go env 输出:

set GO111MODULE=
set GOARCH=amd64
set GOBIN=
set GOCACHE=xxx\AppData\Local\go-build
set GOENV=xxx\AppData\Roaming\go\env
set GOEXE=.exe
set GOEXPERIMENT=
set GOFLAGS=
set GOHOSTARCH=amd64
set GOHOSTOS=windows
set GOINSECURE=
set GOMODCACHE=xxx\gopath-1.21.1-x64\pkg\mod
set GONOPROXY=
set GONOSUMDB=
set GOOS=windows
set GOPATH=xxx\gopath-1.21.1-x64/
set GOPRIVATE=
set GOPROXY=https://proxy.golang.org,direct
set GOROOT=xxx\go-1.21.1-x64
set GOSUMDB=sum.golang.org
set GOTMPDIR=
set GOTOOLCHAIN=auto
set GOTOOLDIR=xxx\go-1.21.1-x64\pkg\tool\windows_amd64
set GOVCS=
set GOVERSION=go1.21.1
set GCCGO=gccgo
set GOAMD64=v1
set AR=ar
set CC=gcc
set CXX=g++
set CGO_ENABLED=1
set GOMOD=xxx\tmp\go.mod
set GOWORK=
set CGO_CFLAGS=-O2 -g
set CGO_CPPFLAGS=
set CGO_CXXFLAGS=-O2 -g
set CGO_FFLAGS=-O2 -g
set CGO_LDFLAGS=-O2 -g
set PKG_CONFIG=pkg-config
set GOGCCFLAGS=-m64 -mthreads -Wl,--no-gc-sections -fmessage-length=0 -ffile-prefix-map=xxx\AppData\Local\Temp\go-build3688887345=/tmp/go-build -gno-record-gcc-switches
@ying32
Copy link
Owner

ying32 commented May 14, 2024

我用go1.22.3都没问题。自定义加载指定路径liblcl,例子customLibTest

func init() {
        // 目标位置liblcl.dll
	libname.LibName = "C:\\test\\liblcl.dll"
}

@funte
Copy link
Author

funte commented May 14, 2024

@ying32
复现项目在这里 https://github.com/funte/hello, 我不了解 golang 管理 package 的底层机制, 但是似乎 govcl 总是先于 hello/lib 被初始化.

@ying32
Copy link
Owner

ying32 commented May 14, 2024

你这样肯定加载不了, go是按包名除了按依赖初顺序初始化,另外就是按从小到大排序的初始化的,在26个字母里g是在l前面的,你看我例子里前面都用了个a用于保证在govcl前面初始化包。

@funte funte closed this as completed May 14, 2024
@funte funte reopened this May 17, 2024
@funte
Copy link
Author

funte commented May 17, 2024

@ying32
复现项目稍微修改后又不行了, 感觉有点诡异.

	// 注释掉这两行代码后程序正常.
	var hash = md5.Sum([]byte(liblcl))
	liblclHash = hex.EncodeToString(hash[:])

@ying32
Copy link
Owner

ying32 commented May 18, 2024

看不明白你这个操作。
如果你是想将liblcl打包到exe,文档有的,只需要编译时添加一个tag即可

@funte funte closed this as completed May 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants