Linking Error with Confluent Kafka Go Package and MSYS2 GCC on Windows 11

Linking Error with Confluent Kafka Go Package and MSYS2 GCC on Windows 11

Description

I am experiencing a linking error when building a Go application with the confluent-kafka-go package on Windows 11, using MSYS2 GCC. The error occurs during the linking phase, indicating unresolved references to __imp__vsnprintf_s and _setjmp.

$ go build main.go
# command-line-arguments
C:\Program Files\Go\pkg\tool\windows_amd64\link.exe: running gcc failed: exit status 1
C:/msys64/ucrt64/bin/../lib/gcc/x86_64-w64-mingw32/13.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/Users/Thadeu/go/pkg/mod/github.com/confluentinc/confluent-kafka-go/v2@v2.3.0/kafka/librdkafka_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/13.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/Users/Thadeu/go/pkg/mod/github.com/confluentinc/confluent-kafka-go/v2@v2.3.0/kafka/librdkafka_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/13.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/Users/Thadeu/go/pkg/mod/github.com/confluentinc/confluent-kafka-go/v2@v2.3.0/kafka/librdkafka_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/13.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/Users/Thadeu/go/pkg/mod/github.com/confluentinc/confluent-kafka-go/v2@v2.3.0/kafka/librdkafka_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/13.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/Users/Thadeu/go/pkg/mod/github.com/confluentinc/confluent-kafka-go/v2@v2.3.0/kafka/librdkafka_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/13.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/Users/Thadeu/go/pkg/mod/github.com/confluentinc/confluent-kafka-go/v2@v2.3.0/kafka/librdkafka_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/13.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/Users/Thadeu/go/pkg/mod/github.com/confluentinc/confluent-kafka-go/v2@v2.3.0/kafka/librdkafka_vendor/librdkafka_windows.a(regexp.c.obj):(.text+0x29fe): undefined reference to `_setjmp'
collect2.exe: error: ld returned 1 exit status

How to reproduce

Set up a Go environment on Windows 11 64-bit.
Install MSYS2 GCC.
Set "CGO_ENABLED": "1"
Try building a Go application that imports confluent-kafka-go.

Environment:

OS: Windows 11 64-bit
Golang version: 1.21.5
GCC version: 13.2.0
Confluent Kafka Go Package version: v2.3.0

What I've Tried:

Updating GCC to the latest version through MSYS2. MSYS2 Guide
Reinstalling confluent-kafka-go package with go get -u.
Despite these efforts, the issue persists. I've ensured that CGO_ENABLED is set to 1 and that the C compiler is correctly included in the PATH.

Question: Has anyone encountered a similar issue or can provide insights into resolving these linker errors? Any suggestions on additional steps or alternative configurations that might work for this setup?

Author

ThadeuFerreira commented on Dec 19, 2023

This is exactly the same issue from here.
#889

RathegaSathyamurthi commented on Jan 5 • 

edited 

@ThadeuFerreira I also faced similar errors.
One solution that worked for me was installing gcc from TDM-GCC 10.3.0 release | tdm-gcc.
Once installed add the bin and gcc.exe paths to environment variables(either remove old gcc path or add the new paths above the old paths for it to be effective) and restart IDE to update the new variables. After this go run was able to start my application.

相关推荐

  1. 作业2.11

    2024-07-12 02:22:02       46 阅读
  2. 2024.<span style='color:red;'>2</span>.<span style='color:red;'>11</span>

    2024.2.11

    2024-07-12 02:22:02      51 阅读
  3. 3.11笔记2

    2024-07-12 02:22:02       30 阅读

最近更新

  1. docker php8.1+nginx base 镜像 dockerfile 配置

    2024-07-12 02:22:02       66 阅读
  2. Could not load dynamic library ‘cudart64_100.dll‘

    2024-07-12 02:22:02       70 阅读
  3. 在Django里面运行非项目文件

    2024-07-12 02:22:02       57 阅读
  4. Python语言-面向对象

    2024-07-12 02:22:02       68 阅读

热门阅读

  1. 在conda虚拟环境中安装llama-parse依赖

    2024-07-12 02:22:02       20 阅读
  2. Sugon RackServer服务器监控指标解读

    2024-07-12 02:22:02       27 阅读
  3. 区块链技术的应用场景和优势。

    2024-07-12 02:22:02       22 阅读
  4. 笔记第二弹

    2024-07-12 02:22:02       26 阅读
  5. 小程序 全局数据共享 getApp()

    2024-07-12 02:22:02       21 阅读
  6. 算法·二分

    2024-07-12 02:22:02       17 阅读
  7. 解决AssertionError: Negative indexing is not supported

    2024-07-12 02:22:02       23 阅读