searchusermenu
  • 发布文章
  • 消息中心
点赞
收藏
评论
分享
原创

windows下使用confluent-kafka-go包报错undefined: kafka.Pr

2024-11-27 09:37:20
210
0

windows下使用confluent-kafka-go包报错undefined: kafka.Producer

报错undefined: kafka.Producer

打开ide终端

执行go env -w CGO_ENABLED=1

继续报错报错

cgo: C compiler "gcc" not found: exec: "gcc": executable file not found in %PATH%

安装gcc

下载

*gcc官网下载:​

1.png

下载README.rst.old,找到红框后面的下载地址

2.png

下载完成后,解压

添加环境变量

右键此电脑—>属性—>高级系统设置—>环境变量

找到下面的系统变量,新增环境变量,值就是上面解压后的bin文件的路径,例如D:\mingw64\bin

3.png

验证

cmd打开命令提示符,输入gcc -v

4.png

然后继续报错

D:\software\go\pkg\tool\windows_amd64\link.exe: running gcc failed: exit status 1
C:/Users/Administrator/go/pkg/mod/github.com/confluentinc/confluent-kafka-go@v1.9.2/kafka/librdkafka_vendor/librdkafka_windows.a(rdkafka_error.c.obj):(.text+0x5ca): undefined reference to `__imp__wassert'
C:/Users/Administrator/go/pkg/mod/github.com/confluentinc/confluent-kafka-go@v1.9.2/kafka/librdkafka_vendor/librdkafka_windows.a(rdkafka_error.c.obj):(.text+0x63d): undefined reference to `__imp__wassert'
C:/Users/Administrator/go/pkg/mod/github.com/confluentinc/confluent-kafka-go@v1.9.2/kafka/librdkafka_vendor/librdkafka_windows.a(rdkafka_error.c.obj):(.text+0x700): undefined reference to `__imp__wassert'
C:/Users/Administrator/go/pkg/mod/github.com/confluentinc/confluent-kafka-go@v1.9.2/kafka/librdkafka_vendor/librdkafka_windows.a(rdkafka_error.c.obj):(.text+0xf89): undefined reference to `__imp__wassert'
C:/Users/Administrator/go/pkg/mod/github.com/confluentinc/confluent-kafka-go@v1.9.2/kafka/librdkafka_vendor/librdkafka_windows.a(rdkafka_error.c.obj):(.text+0x10d5): undefined reference to `__imp__wassert'
C:/Users/Administrator/go/pkg/mod/github.com/confluentinc/confluent-kafka-go@v1.9.2/kafka/librdkafka_vendor/librdkafka_windows.a(rdkafka_error.c.obj):(.text+0x1158): more undefined references to `__imp__wassert' follow
collect2.exe: error: ld returned 1 exit status
​

解决办法:找到confluent-kafka-go包下的build_windows.go文件

**将 -lmsvcr110 增加到 **\#cgo LDFLAGS: ${SRCDIR}/librdkafka_vendor/librdkafka_windows.a -lws2_32 -lsecur32 -lcrypt32后面

再次运行代码即可

如果编译成功后,如果提示找不到 msvcr120d.dll, 下载个放到 C:\Windows\System32 下即可

0条评论
0 / 1000
张****宇
5文章数
0粉丝数
张****宇
5 文章 | 0 粉丝
原创

windows下使用confluent-kafka-go包报错undefined: kafka.Pr

2024-11-27 09:37:20
210
0

windows下使用confluent-kafka-go包报错undefined: kafka.Producer

报错undefined: kafka.Producer

打开ide终端

执行go env -w CGO_ENABLED=1

继续报错报错

cgo: C compiler "gcc" not found: exec: "gcc": executable file not found in %PATH%

安装gcc

下载

*gcc官网下载:​

1.png

下载README.rst.old,找到红框后面的下载地址

2.png

下载完成后,解压

添加环境变量

右键此电脑—>属性—>高级系统设置—>环境变量

找到下面的系统变量,新增环境变量,值就是上面解压后的bin文件的路径,例如D:\mingw64\bin

3.png

验证

cmd打开命令提示符,输入gcc -v

4.png

然后继续报错

D:\software\go\pkg\tool\windows_amd64\link.exe: running gcc failed: exit status 1
C:/Users/Administrator/go/pkg/mod/github.com/confluentinc/confluent-kafka-go@v1.9.2/kafka/librdkafka_vendor/librdkafka_windows.a(rdkafka_error.c.obj):(.text+0x5ca): undefined reference to `__imp__wassert'
C:/Users/Administrator/go/pkg/mod/github.com/confluentinc/confluent-kafka-go@v1.9.2/kafka/librdkafka_vendor/librdkafka_windows.a(rdkafka_error.c.obj):(.text+0x63d): undefined reference to `__imp__wassert'
C:/Users/Administrator/go/pkg/mod/github.com/confluentinc/confluent-kafka-go@v1.9.2/kafka/librdkafka_vendor/librdkafka_windows.a(rdkafka_error.c.obj):(.text+0x700): undefined reference to `__imp__wassert'
C:/Users/Administrator/go/pkg/mod/github.com/confluentinc/confluent-kafka-go@v1.9.2/kafka/librdkafka_vendor/librdkafka_windows.a(rdkafka_error.c.obj):(.text+0xf89): undefined reference to `__imp__wassert'
C:/Users/Administrator/go/pkg/mod/github.com/confluentinc/confluent-kafka-go@v1.9.2/kafka/librdkafka_vendor/librdkafka_windows.a(rdkafka_error.c.obj):(.text+0x10d5): undefined reference to `__imp__wassert'
C:/Users/Administrator/go/pkg/mod/github.com/confluentinc/confluent-kafka-go@v1.9.2/kafka/librdkafka_vendor/librdkafka_windows.a(rdkafka_error.c.obj):(.text+0x1158): more undefined references to `__imp__wassert' follow
collect2.exe: error: ld returned 1 exit status
​

解决办法:找到confluent-kafka-go包下的build_windows.go文件

**将 -lmsvcr110 增加到 **\#cgo LDFLAGS: ${SRCDIR}/librdkafka_vendor/librdkafka_windows.a -lws2_32 -lsecur32 -lcrypt32后面

再次运行代码即可

如果编译成功后,如果提示找不到 msvcr120d.dll, 下载个放到 C:\Windows\System32 下即可

文章来自个人专栏
python并发编程
5 文章 | 1 订阅
0条评论
0 / 1000
请输入你的评论
0
0