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 安卓adb backup备份应用数据失败
  • ¥15 eclipse运行项目时遇到的问题
  • ¥15 关于#c##的问题:最近需要用CAT工具Trados进行一些开发
  • ¥15 南大pa1 小游戏没有界面,并且报了如下错误,尝试过换显卡驱动,但是好像不行
  • ¥15 没有证书,nginx怎么反向代理到只能接受https的公网网站
  • ¥50 成都蓉城足球俱乐部小程序抢票
  • ¥15 yolov7训练自己的数据集
  • ¥15 esp8266与51单片机连接问题(标签-单片机|关键词-串口)(相关搜索:51单片机|单片机|测试代码)
  • ¥15 电力市场出清matlab yalmip kkt 双层优化问题
  • ¥30 ros小车路径规划实现不了,如何解决?(操作系统-ubuntu)