giu icon indicating copy to clipboard operation
giu copied to clipboard

Windows UCRT MinGW - link failed

Open alchem1ster opened this issue 3 years ago • 5 comments

What happend?

Hello, It's A Me, Mario! 😆 I'm here again, and again I'm having trouble building on Windows 10. My old problem was successfully solved: https://github.com/AllenDang/giu/issues/156

But winlibs switched to UCRT releases, which are different from MSVCRT. And it looks like giu has a problem with that. Any attempt to run the code results in the following errors:

Errors
PS O:\Projects\giu\helloworld> go run .\main.go
# command-line-arguments
O:\GoLang\pkg\tool\windows_amd64\link.exe: running g++ failed: exit status 1
o:/mingw/bin/../lib/gcc/x86_64-w64-mingw32/11.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:\Users\PROFES~1\AppData\Local\Temp\go-link-141367154\000082.o: in function `_cgo_preinit_init':
c:\go\src\runtime\cgo/gcc_libinit_windows.c:30: undefined reference to `__imp___iob_func'
o:/mingw/bin/../lib/gcc/x86_64-w64-mingw32/11.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:\Users\PROFES~1\AppData\Local\Temp\go-link-141367154\000082.o: in function `x_cgo_sys_thread_create':
c:\go\src\runtime\cgo/gcc_libinit_windows.c:60: undefined reference to `__imp___iob_func'
o:/mingw/bin/../lib/gcc/x86_64-w64-mingw32/11.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:\Users\PROFES~1\AppData\Local\Temp\go-link-141367154\000082.o: in function `x_cgo_notify_runtime_init_done':
c:\go\src\runtime\cgo/gcc_libinit_windows.c:101: undefined reference to `__imp___iob_func'
o:/mingw/bin/../lib/gcc/x86_64-w64-mingw32/11.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:\Users\PROFES~1\AppData\Local\Temp\go-link-141367154\000083.o: in function `x_cgo_thread_start':
c:\go\src\runtime\cgo/gcc_util.c:18: undefined reference to `__imp___iob_func'
o:/mingw/bin/../lib/gcc/x86_64-w64-mingw32/11.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:\Users\PROFES~1\AppData\Local\Temp\go-link-141367154\000084.o: in function `_cgo_sys_thread_start':
c:\go\src\runtime\cgo/gcc_windows_amd64.c:31: undefined reference to `__imp___iob_func'
collect2.exe: error: ld returned 1 exit status

Changing the MinGW build to the previous MSVCRT solves the problem. but its not the real solution.

Code example

main.go
package main

import (
	g "github.com/AllenDang/giu"
)

var content string

func loop() {
	g.SingleWindow().Layout(
		g.Label("Hello world from giu"),
		g.InputTextMultiline(&content).Size(g.Auto, g.Auto),
	)
}

func main() {
	wnd := g.NewMasterWindow("Hello world", 400, 200, 0)
	wnd.Run(loop)
}

To Reproduce

  1. Install latest MinGW UCRT
  2. Try to run any example

Version

v0.5.6 (latest)

OS

Windows 10 21H2 19044.1503

alchem1ster avatar Feb 02 '22 14:02 alchem1ster

@HACKERALERT Do you have time to take a look at this? I'm not familiar with windows's cpp compilers...

AllenDang avatar Feb 03 '22 03:02 AllenDang

I'm not too sure to he honest, I'm not a C expert. What I usually do is install TDM-GCC, which is basically a simplified C/C++ compiler that installs in a few clicks and automatically sets up PATH variables, etc. I've never had a problem with CGo using my TDM-GCC installation, and it's my go-to. So if all goes wrong, that's a choice. But other than that, I don't know much 😅

HACKERALERT avatar Feb 03 '22 03:02 HACKERALERT

TDM-GCC is a fork of MinGW when everything was on MSVCRT (reason why it works with). If it can't be fixed on your end, then you can close the problem 😃

alchem1ster avatar Feb 04 '22 13:02 alchem1ster

Hi @alchem1ster

The Win10 install on the dev box has version 19044.1526 I found that manually adding just the mingw64\bin to the path seemed to resolve some random issues I was seeing.

Maybe try uninstalling the whole thing and just linking direct to the bin folder. Using the readme linked repo for ming64 and the latest version

robyeates avatar Feb 12 '22 07:02 robyeates

Hello @robyeates This is exactly the PATH I have set for the compiler winlibs_mingw64/bin. I don't think this is a problem in this case because the MSVCRT version works without any errors. This issue link is exactly to USCRT.

alchem1ster avatar Feb 12 '22 11:02 alchem1ster

@alchem1ster do you experience this error all the time? As far as I remember I managed to compile giu on my windows 10 using TDM-gcc. Can we close it?

gucio321 avatar May 10 '23 13:05 gucio321

Closing as likely fixed. Feel free to ping me if you think it should be re-opened.

gucio321 avatar May 17 '23 10:05 gucio321