gpt4 book ai didi

go - GCC 未定义的构建引用

转载 作者:数据小太阳 更新时间:2023-10-29 03:11:37 24 4
gpt4 key购买 nike

我正在尝试使用 golang 为 windows amd64 构建一个 exe。除了“go run”或“go build”之外,一切都运行顺利。构建过程中断了来自 github.com/andlabs/ui 的包的 gcc 编译。跟踪如下:

$ go build
# gitlab.com/asnossascenas/dbRegistration/ui
C:\Users\Pat\AppData\Local\Temp\go-
build167765418\gitlab.com\asnossascenas\dbRegistration\ui\_obj\table.cgo2.o:
In function `_cgo_1e2a701ee86d_Cfunc_uiNewTable':
/tmp/go-build\gitlab.com\asnossascenas\dbRegistration\ui\_obj/cgo-gcc-
prolog:66: undefined reference to `uiNewTable'
C:\Users\Pat\AppData\Local\Temp\go-
build167765418\gitlab.com\asnossascenas\dbRegistration\ui\_obj\table.cgo2.o:
In function `_cgo_1e2a701ee86d_Cfunc_uiNewTableModel':
/tmp/go-build\gitlab.com\asnossascenas\dbRegistration\ui\_obj/cgo-gcc-
prolog:83: undefined reference to `uiNewTableModel'
C:\Users\Pat\AppData\Local\Temp\go-
build167765418\gitlab.com\asnossascenas\dbRegistration\ui\_obj\table.cgo2.o:
In function `_cgo_1e2a701ee86d_Cfunc_uiTableAppendTextColumn':
/tmp/go-build\gitlab.com\asnossascenas\dbRegistration\ui\_obj/cgo-gcc-
prolog:103: undefined reference to `uiTableAppendTextColumn'
C:\Users\Pat\AppData\Local\Temp\go-
build167765418\gitlab.com\asnossascenas\dbRegistration\ui\_obj\table.cgo2.o:
In function `_cgo_1e2a701ee86d_Cfunc_uiTableGetSelection':
/tmp/go-build\gitlab.com\asnossascenas\dbRegistration\ui\_obj/cgo-gcc-
prolog:120: undefined reference to `uiTableGetSelection'
C:\Users\Pat\AppData\Local\Temp\go-
build167765418\gitlab.com\asnossascenas\dbRegistration\ui\_obj\table.cgo2.o:
In function `_cgo_1e2a701ee86d_Cfunc_uiTableIterAdvance':
/tmp/go-build\gitlab.com\asnossascenas\dbRegistration\ui\_obj/cgo-gcc-
prolog:138: undefined reference to `uiTableIterAdvance'
C:\Users\Pat\AppData\Local\Temp\go-
build167765418\gitlab.com\asnossascenas\dbRegistration\ui\_obj\table.cgo2.o:
In function `_cgo_1e2a701ee86d_Cfunc_uiTableIterCurrent':
/tmp/go-build\gitlab.com\asnossascenas\dbRegistration\ui\_obj/cgo-gcc-
prolog:168: undefined reference to `uiTableIterCurrent'
C:\Users\Pat\AppData\Local\Temp\go-
build167765418\gitlab.com\asnossascenas\dbRegistration\ui\_obj\table.cgo2.o:
In function `realuiTableOnSelectionChanged':
C:/GoPath/src/gitlab.com/asnossascenas/dbRegistration/ui/table.go:12:
undefined reference to `uiTableOnSelectionChanged'
C:\Users\Pat\AppData\Local\Temp\go-
build167765418\gitlab.com\asnossascenas\dbRegistration\ui\_obj\table.cgo2.o:
In function `_cgo_1e2a701ee86d_Cfunc_uiFreeTableModel':
/tmp/go-build\gitlab.com\asnossascenas\dbRegistration\ui\_obj/cgo-gcc-
prolog:49: undefined reference to `uiFreeTableModel'
C:\Users\Pat\AppData\Local\Temp\go-
build167765418\gitlab.com\asnossascenas\dbRegistration\ui\_obj\table.cgo2.o:
In function `_cgo_1e2a701ee86d_Cfunc_uiTableIterComplete':
/tmp/go-build\gitlab.com\asnossascenas\dbRegistration\ui\_obj/cgo-gcc-
prolog:152: undefined reference to `uiTableIterComplete'
C:\Users\Pat\AppData\Local\Temp\go-
build167765418\gitlab.com\asnossascenas\dbRegistration\ui\_obj\table.cgo2.o:
In function `_cgo_1e2a701ee86d_Cfunc_uiTableModelRowChanged':
/tmp/go-build\gitlab.com\asnossascenas\dbRegistration\ui\_obj/cgo-gcc-
prolog:184: undefined reference to `uiTableModelRowChanged'
C:\Users\Pat\AppData\Local\Temp\go-
build167765418\gitlab.com\asnossascenas\dbRegistration\ui\_obj\table.cgo2.o:
In function `_cgo_1e2a701ee86d_Cfunc_uiTableModelRowDeleted':
/tmp/go-build\gitlab.com\asnossascenas\dbRegistration\ui\_obj/cgo-gcc-
prolog:198: undefined reference to `uiTableModelRowDeleted'
C:\Users\Pat\AppData\Local\Temp\go-
build167765418\gitlab.com\asnossascenas\dbRegistration\ui\_obj\table.cgo2.o:
In function `_cgo_1e2a701ee86d_Cfunc_uiTableModelRowInserted':
/tmp/go-build\gitlab.com\asnossascenas\dbRegistration\ui\_obj/cgo-gcc-
prolog:212: undefined reference to `uiTableModelRowInserted'
C:\Users\Pat\AppData\Local\Temp\gobuild167765418\gitlab.com
\asnossascenas\dbRegistration\ui\_obj\tablemodelhandler.cgo2.o: In function
`_cgo_1e2a701ee86d_Cfunc_uiTableModelStrdup':
/tmp/go-build\gitlab.com\asnossascenas\dbRegistration\ui\_obj/cgo-gcc-
prolog:68: undefined reference to `uiTableModelStrdup'o `uiTableModelStrdup'
function `msgbox':
C:/GoPath/src/gitlab.com/asnossascenas/
dbRegistration/ui/libui_windows_amd64.a(stddialogs.cpp.obj): In function
`msgbox':E:/github.com/andlabs/libui/windows/stddialogs.cpp:113: undefined
reference to `__imp_TaskDialog'
collect2.exe: error: ld returned 1 exit status

我最初尝试从 linux 交叉编译到 windows,但问题大致相同,所以我想这是我应该用来构建它的标志的问题,或者我可能缺少一些与依赖相关的东西......

我尝试使用 CGO_ENABLED=1 和 linux 上几乎所有其他可能的标志组合进行交叉编译,有时会触发错误

gcc: error: unrecognized command line option ‘-mthreads’

最终我决定我应该转移到 Windows 并进行 native 编译,这似乎不起作用。

我愿意提供您可能需要的任何更多信息来帮助我解决这个问题。

最佳答案

根据the installation instructions for the ui package你需要 install MingW并设置一些环境变量来构建它:

set CGO_ENABLED=1
set CC=C:\PROGRA~1\mingw-w64\x86_64-7.2.0-win32-seh-rt_v5-rev1\mingw64\bin\gcc.exe
set CXX=C:\PROGRA~1\mingw-w64\x86_64-7.2.0-win32-seh-rt_v5-rev1\mingw64\bin\g++.exe
go build -ldflags -H=windowsgui

关于go - GCC 未定义的构建引用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50283375/

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