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++LNK2001 无法解析的外部符号
  • ¥50 安装pyaudiokits失败
  • ¥15 计组这些题应该咋做呀
  • ¥60 更换迈创SOL6M4AE卡的时候,驱动要重新装才能使用,怎么解决?
  • ¥15 让node服务器有自动加载文件的功能
  • ¥15 jmeter脚本回放有的是对的有的是错的
  • ¥15 r语言蛋白组学相关问题
  • ¥15 Python时间序列如何拟合疏系数模型
  • ¥15 求学软件的前人们指明方向🥺
  • ¥50 如何增强飞上天的树莓派的热点信号强度,以使得笔记本可以在地面实现远程桌面连接