doufu4333 2018-05-11 00:36
浏览 743

GCC在构建时未定义的引用

I am trying to build an exe for windows amd64 using golang. Everything is running smoothly except on "go run" or "go build". The build process is breaking on gcc compile of the package from github.com/andlabs/ui. The trace goes as follows:

$ 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

I initially tried to crosscompile from linux to windows having roughly the same problem so I guess it's a matter of either the flags I should use to build it or maybe I am missing something dependency related...

I tried using CGO_ENABLED=1 and pretty much every other combination of flags possible on linux to crosscompile, sometimes triggering the error

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

eventually I decided I should move to Windows and compile natively, which doesn't seem to be working.

I am willing to provide any more information you might need to help me figure this out.

  • 写回答

1条回答

  • dongxu198714 2018-05-11 01:55
    关注

    According to the the installation instructions for the ui package you will need to install MingW and set some some environment variables to get it to build:

    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
    
    评论

报告相同问题?

悬赏问题

  • ¥15 c程序不知道为什么得不到结果
  • ¥40 复杂的限制性的商函数处理
  • ¥15 程序不包含适用于入口点的静态Main方法
  • ¥15 素材场景中光线烘焙后灯光失效
  • ¥15 请教一下各位,为什么我这个没有实现模拟点击
  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置