confluent-kafka-go icon indicating copy to clipboard operation
confluent-kafka-go copied to clipboard

Can't build on Windows 10, linking issue

Open plkn opened this issue 2 years ago • 6 comments

Description

I'm trying to build on Windows with go build ./.... Get the following linking errors. Please help.

PS C:\sources\opensource\confluent-kafka-go> go build ./...
# github.com/confluentinc/confluent-kafka-go/kafka/go_rdkafka_generr
C:\Users\pavel\sdk\go1.19.1\pkg\tool\windows_amd64\link.exe: running gcc failed: exit status 1
C:/msys64/ucrt64/bin/../lib/gcc/x86_64-w64-mingw32/12.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:\Users\pavel\AppData\Local\Temp\go-link-3181282
660\000026.o: in function `_cgo_preinit_init':
\\_\_\runtime\cgo/gcc_libinit_windows.c:40: undefined reference to `__imp___iob_func'
C:/msys64/ucrt64/bin/../lib/gcc/x86_64-w64-mingw32/12.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:\Users\pavel\AppData\Local\Temp\go-link-3181282
660\000026.o: in function `x_cgo_notify_runtime_init_done':
\\_\_\runtime\cgo/gcc_libinit_windows.c:105: undefined reference to `__imp___iob_func'
C:/msys64/ucrt64/bin/../lib/gcc/x86_64-w64-mingw32/12.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:\Users\pavel\AppData\Local\Temp\go-link-3181282
660\000026.o: in function `_cgo_beginthread':
\\_\_\runtime\cgo/gcc_libinit_windows.c:149: undefined reference to `__imp___iob_func'
C:/msys64/ucrt64/bin/../lib/gcc/x86_64-w64-mingw32/12.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:\Users\pavel\AppData\Local\Temp\go-link-3181282
660\000027.o: in function `x_cgo_thread_start':
\\_\_\runtime\cgo/gcc_util.c:18: undefined reference to `__imp___iob_func'
C:/msys64/ucrt64/bin/../lib/gcc/x86_64-w64-mingw32/12.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/sources/opensource/confluent-kafka-go/kafka/li
brdkafka_vendor/librdkafka_windows.a(rdkafka_error.c.obj):(.text+0x8e): undefined reference to `__imp__vsnprintf_s'
C:/msys64/ucrt64/bin/../lib/gcc/x86_64-w64-mingw32/12.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/sources/opensource/confluent-kafka-go/kafka/li
brdkafka_vendor/librdkafka_windows.a(rdkafka_mock.c.obj):(.text+0x8e): undefined reference to `__imp__vsnprintf_s'
C:/msys64/ucrt64/bin/../lib/gcc/x86_64-w64-mingw32/12.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/sources/opensource/confluent-kafka-go/kafka/li
brdkafka_vendor/librdkafka_windows.a(rdkafka_txnmgr.c.obj):(.text+0xca): undefined reference to `__imp__vsnprintf_s'
C:/msys64/ucrt64/bin/../lib/gcc/x86_64-w64-mingw32/12.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/sources/opensource/confluent-kafka-go/kafka/li
brdkafka_vendor/librdkafka_windows.a(rdkafka_idempotence.c.obj):(.text+0x8e): undefined reference to `__imp__vsnprintf_s'
C:/msys64/ucrt64/bin/../lib/gcc/x86_64-w64-mingw32/12.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/sources/opensource/confluent-kafka-go/kafka/li
brdkafka_vendor/librdkafka_windows.a(rdkafka_aux.c.obj):(.text+0x8e): undefined reference to `__imp__vsnprintf_s'
C:/msys64/ucrt64/bin/../lib/gcc/x86_64-w64-mingw32/12.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/sources/opensource/confluent-kafka-go/kafka/li
brdkafka_vendor/librdkafka_windows.a(rdkafka_admin.c.obj):(.text+0x8e): more undefined references to `__imp__vsnprintf_s' follow
C:/msys64/ucrt64/bin/../lib/gcc/x86_64-w64-mingw32/12.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/sources/opensource/confluent-kafka-go/kafka/li
brdkafka_vendor/librdkafka_windows.a(regexp.c.obj):(.text+0x29fa): undefined reference to `_setjmp'
collect2.exe: error: ld returned 1 exit status

I've installed gcc using https://www.msys2.org/.

PS C:\Users\pavel> gcc --version
gcc.exe (Rev4, Built by MSYS2 project) 12.2.0
Copyright (C) 2022 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
PS C:\Users\pavel> Get-ComputerInfo | select WindowsVersion

WindowsVersion
--------------
2009

plkn avatar Nov 04 '22 13:11 plkn

this client is not currently supported on windows unfortunately.

librdkafka is though, so you might have some luck in perservering.

mhowlett avatar Nov 04 '22 15:11 mhowlett

https://learn.microsoft.com/en-us/cpp/porting/visual-cpp-change-history-2003-2015?redirectedfrom=MSDN&view=msvc-170#stdio_and_conio

edenhill avatar Nov 04 '22 16:11 edenhill

Install mingw-w64-x86_64-toolchain without ucrt works for me.

etoyz avatar Apr 29 '24 07:04 etoyz

Install mingw-w64-x86_64-toolchain without ucrt works for me.

Thanks your reply, this work for me. I installed "MSYS2 MinGW GCC" in windows11, which could be download from "https://www.msys2.org/", and open a terminal of msys2, then run all commands below in this terminal: $ pacman -Syu $ pacman -S base-devel $ pacman -S mingw-w64-x86_64-toolchain $ pacman -Q -e $ pacman -S mingw-w64-ucrt-x86_64-gcc finally, I add the "D:\Program Files\msys64\mingw64\bin" into system env PATH (“D:\Program Files\msys64” is my installation dirctory of msys64)

image

jiangsanyin avatar Jun 05 '24 15:06 jiangsanyin

@jiangsanyin Thanks it really worked

maverick-ai avatar Jul 11 '24 11:07 maverick-ai

it's work for me also. can be explained in documentation ?

mcarbonneaux avatar Aug 07 '24 12:08 mcarbonneaux