Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Windows MinGW Static Library #564

Merged
merged 19 commits into from
Apr 20, 2021
Merged

Add Windows MinGW Static Library #564

merged 19 commits into from
Apr 20, 2021

Conversation

neptoess
Copy link
Contributor

@neptoess neptoess commented Nov 5, 2020

Re-opening #555
Resolves #128

@ghost
Copy link

ghost commented Nov 5, 2020

@confluentinc It looks like @neptoess just signed our Contributor License Agreement. 👍

Always at your service,

clabot

@neptoess
Copy link
Contributor Author

neptoess commented Nov 5, 2020

@edenhill ,
I will add the Travis CI worker in this PR

@neptoess neptoess marked this pull request as draft November 5, 2020 15:51
@neptoess neptoess changed the base branch from import_v1.5.2 to master November 5, 2020 20:18
@neptoess
Copy link
Contributor Author

neptoess commented Nov 5, 2020

@edenhill
Seeing this in the Travis log

=== RUN   TestProducerOAuthBearerConfig
    TestProducerOAuthBearerConfig: producer_test.go:283: NewProducer failed: No provider for SASL mechanism OAUTHBEARER: recompile librdkafka with openssl support. Current build options: PLAIN WindowsSSPI(GSSAPI)
--- FAIL: TestProducerOAuthBearerConfig (0.00s)

Since it seems intentional that PLAIN and GSSAPI are the only SASL options on Windows, should this test be skipped on Windows builds?

@neptoess neptoess marked this pull request as ready for review November 6, 2020 15:09
@neptoess
Copy link
Contributor Author

neptoess commented Nov 6, 2020

build_windows.go and librdkafka_windows.a came from a local librdkafka v1.5.2 build, but once confluentinc/librdkafka#3130 is merged, Travis will automatically build the static Windows bundle.

@neptoess
Copy link
Contributor Author

neptoess commented Apr 7, 2021

@edenhill
Now that Travis is building static librdkafka bundles for Windows, what else do we need to get this PR merged?

Copy link
Contributor

@edenhill edenhill left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't do the actual import here, we'll do that for the upcoming 1.7.0 release, just update the tooling as needed. Thanks

.travis.yml Show resolved Hide resolved
.travis.yml Outdated Show resolved Hide resolved
.travis.yml Show resolved Hide resolved
kafka/librdkafka_vendor/bundle-import.sh Outdated Show resolved Hide resolved
@neptoess
Copy link
Contributor Author

neptoess commented Apr 7, 2021

@edenhill

Don't do the actual import here, we'll do that for the upcoming 1.7.0 release, just update the tooling as needed. Thanks

This is done, but note that this will make the Travis Windows jobs fail (since build_windows.go and librdkafka_windows.a are missing)

@neptoess
Copy link
Contributor Author

@edenhill
I think this should be ready to merge. Need anything else from me?

@edenhill edenhill merged commit 80c58f8 into confluentinc:master Apr 20, 2021
@edenhill
Copy link
Contributor

Thanks alot for this!

@edenhill
Copy link
Contributor

@neptoess Hey, I just pushed an RC branch with your new Windows builds, can you try it out on Windows? (this RC branch will not be merged, to keep the repo size down).
https://github.com/confluentinc/confluent-kafka-go/tree/import_v1.7.0-RC6

@neptoess
Copy link
Contributor Author

@neptoess Hey, I just pushed an RC branch with your new Windows builds, can you try it out on Windows? (this RC branch will not be merged, to keep the repo size down).
https://github.com/confluentinc/confluent-kafka-go/tree/import_v1.7.0-RC6

@edenhill
Tested locally (both producer and consumer) and it looks to be working well. I see the Travis build (https://travis-ci.org/github/confluentinc/confluent-kafka-go/builds/768834426) worked as well. Good news all around!

@edenhill
Copy link
Contributor

Superb! Thank you for all your hard work on getting this done!

@leonheess
Copy link

This PR sounds like Windows is now supported but the README still says "confluent-kafka-go is not supported on Windows." - can you clarify if and how I can get it to run on Windows?

@neptoess
Copy link
Contributor Author

This PR sounds like Windows is now supported but the README still says "confluent-kafka-go is not supported on Windows." - can you clarify if and how I can get it to run on Windows?

It’s not officially supported, but, as of v1.7.0, a static bundle is being shipped. If you have a working cgo toolchain (the bundle is built with MSYS2 MinGW 64-bit, and is what I’d recommend), it should “just work”

@leonheess
Copy link

It’s not officially supported, but, as of v1.7.0, a static bundle is being shipped. If you have a working cgo toolchain (the bundle is built with MSYS2 MinGW 64-bit, and is what I’d recommend), it should “just work”

Thanks for the quick reply. I'm getting this error:
image
Can you point me in any direction?

@neptoess
Copy link
Contributor Author

It’s not officially supported, but, as of v1.7.0, a static bundle is being shipped. If you have a working cgo toolchain (the bundle is built with MSYS2 MinGW 64-bit, and is what I’d recommend), it should “just work”

Thanks for the quick reply. I'm getting this error:
image
Can you point me in any direction?

Very bizarre. The Travis build and tests worked perfectly fine with this bundle https://travis-ci.org/github/confluentinc/confluent-kafka-go/jobs/770559600

__imp_wassert is defined in the C runtime library. What version of Windows are you running on? What gcc version?

@leonheess
Copy link

leonheess commented May 28, 2021

Very bizarre. The Travis build and tests worked perfectly fine with this bundle https://travis-ci.org/github/confluentinc/confluent-kafka-go/jobs/770559600

I saw that that is why I'm kind of confused

__imp_wassert is defined in the C runtime library. What version of Windows are you running on? What gcc version?

image
image

@neptoess
Copy link
Contributor Author

Very bizarre. The Travis build and tests worked perfectly fine with this bundle https://travis-ci.org/github/confluentinc/confluent-kafka-go/jobs/770559600

I saw that that is why I'm kind of confused

__imp_wassert is defined in the C runtime library. What version of Windows are you running on? What gcc version?

image
image

Hmm. Gcc v8.1.0 is a little outdated. Per https://travis-ci.org/github/edenhill/librdkafka/jobs/770444016#L2714, the v1.7.0 bundle was built with v10.3. Maybe try upgrading?

@leonheess
Copy link

leonheess commented May 28, 2021

Hmm. Gcc v8.1.0 is a little outdated. Per https://travis-ci.org/github/edenhill/librdkafka/jobs/770444016#L2714, the v1.7.0 bundle was built with v10.3. Maybe try upgrading?

I upgraded to v11.1 and it's working! ty so much ❤

eran-levy pushed a commit to eran-levy/confluent-kafka-go that referenced this pull request Apr 9, 2022
@dassio
Copy link

dassio commented Jun 25, 2022

for anyone that trying to build without too much background in C++, here is what i did :
install mingw-w64: pacman -S --needed mingw-w64-x86_64-toolchain
compile with command: env GOOS=windows GOARCH=amd64 CGO_ENABLED=1 CC=x86_64-w64-mingw32-gcc CXX=x86_64-w64-mingw32-g++ CGO_CXXFLAGS="-IC:\msys64\mingw64\include" go build

@neptoess
Copy link
Contributor Author

for anyone that trying to build without too much background in C++, here is what i did :
install mingw-w64: pacman -S --needed mingw-w64-x86_64-toolchain
compile with command: env GOOS=windows GOARCH=amd64 CGO_ENABLED=1 CC=x86_64-w64-mingw32-gcc CXX=x86_64-w64-mingw32-g++ CGO_CXXFLAGS="-IC:\msys64\mingw64\include" go build

If you have C:\msys64\mingw64\bin in your PATH, you shouldn’t need to define all these environment variables. I just do plain old go build

@behoyh
Copy link

behoyh commented Apr 11, 2023

I'm getting error

# command-line-arguments
C:\Program Files\Go\pkg\tool\windows_amd64\link.exe: running gcc failed: exit status 1
C:/Users/bhanna/scoop/apps/mingw/current/bin/../lib/gcc/x86_64-w64-mingw32/12.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:\Users\bhanna\AppData\Local\Temp\go-link-3107212506\000026.o: in function `_cgo_preinit_init':
\\_\_\runtime\cgo/gcc_libinit_windows.c:40: undefined reference to `__imp___iob_func'
C:/Users/bhanna/scoop/apps/mingw/current/bin/../lib/gcc/x86_64-w64-mingw32/12.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:\Users\bhanna\AppData\Local\Temp\go-link-3107212506\000026.o: in function `x_cgo_notify_runtime_init_done':
\\_\_\runtime\cgo/gcc_libinit_windows.c:105: undefined reference to `__imp___iob_func'
C:/Users/bhanna/scoop/apps/mingw/current/bin/../lib/gcc/x86_64-w64-mingw32/12.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:\Users\bhanna\AppData\Local\Temp\go-link-3107212506\000026.o: in function `_cgo_beginthread':
\\_\_\runtime\cgo/gcc_libinit_windows.c:149: undefined reference to `__imp___iob_func'
C:/Users/bhanna/scoop/apps/mingw/current/bin/../lib/gcc/x86_64-w64-mingw32/12.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:\Users\bhanna\AppData\Local\Temp\go-link-3107212506\000027.o: in function `x_cgo_thread_start':
\\_\_\runtime\cgo/gcc_util.c:18: undefined reference to `__imp___iob_func'
C:/Users/bhanna/scoop/apps/mingw/current/bin/../lib/gcc/x86_64-w64-mingw32/12.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/Development/tracer/vendor/github.com/confluentinc/confluent-kafka-go/v2/kafka/librdkafka_vendor/librdkafka_windows.a(rdkafka_error.c.obj):(.text+0x8e): undefined reference to `__imp__vsnprintf_s'
C:/Users/bhanna/scoop/apps/mingw/current/bin/../lib/gcc/x86_64-w64-mingw32/12.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/Development/tracer/vendor/github.com/confluentinc/confluent-kafka-go/v2/kafka/librdkafka_vendor/librdkafka_windows.a(rdkafka_mock.c.obj):(.text+0x8e): undefined reference to `__imp__vsnprintf_s'
C:/Users/bhanna/scoop/apps/mingw/current/bin/../lib/gcc/x86_64-w64-mingw32/12.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/Development/tracer/vendor/github.com/confluentinc/confluent-kafka-go/v2/kafka/librdkafka_vendor/librdkafka_windows.a(rdkafka_txnmgr.c.obj):(.text+0xca): undefined reference to `__imp__vsnprintf_s'
C:/Users/bhanna/scoop/apps/mingw/current/bin/../lib/gcc/x86_64-w64-mingw32/12.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/Development/tracer/vendor/github.com/confluentinc/confluent-kafka-go/v2/kafka/librdkafka_vendor/librdkafka_windows.a(rdkafka_idempotence.c.obj):(.text+0x8e): undefined reference to `__imp__vsnprintf_s'
C:/Users/bhanna/scoop/apps/mingw/current/bin/../lib/gcc/x86_64-w64-mingw32/12.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/Development/tracer/vendor/github.com/confluentinc/confluent-kafka-go/v2/kafka/librdkafka_vendor/librdkafka_windows.a(rdkafka_aux.c.obj):(.text+0x8e): undefined reference to `__imp__vsnprintf_s'
C:/Users/bhanna/scoop/apps/mingw/current/bin/../lib/gcc/x86_64-w64-mingw32/12.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/Development/tracer/vendor/github.com/confluentinc/confluent-kafka-go/v2/kafka/librdkafka_vendor/librdkafka_windows.a(rdkafka_admin.c.obj):(.text+0x8e): more undefined references to `__imp__vsnprintf_s' follow
C:/Users/bhanna/scoop/apps/mingw/current/bin/../lib/gcc/x86_64-w64-mingw32/12.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/Development/tracer/vendor/github.com/confluentinc/confluent-kafka-go/v2/kafka/librdkafka_vendor/librdkafka_windows.a(regexp.c.obj):(.text+0x29fa): undefined reference to `_setjmp'
collect2.exe: error: ld returned 1 exit status

when trying to install with mingw v12.2.0-rt_v10-rev2 installed via Scoop: scoop install mingw

is this supported or is there another way to install?

@neptoess
Copy link
Contributor Author

Not sure about Scoop. The MinGW install I was using was via MSYS2

@behoyh
Copy link

behoyh commented Apr 11, 2023

Thanks for the response, I believe the versions should be the same according to gcc --version:

gcc.exe (x86_64-posix-seh-rev2, Built by MinGW-W64 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.

@behoyh
Copy link

behoyh commented Apr 12, 2023

So as you say, what got this to work was installing MSYS2 version of gcc, via pacman:

update pacman

pacman -Syu

uninstall 32 target gcc if installed

pacman -R gcc

install gcc on x64 targeting x64

pacman -S mingw-w64-x86_64-gcc

Add to PATH:

  • C:\msys64\mingw64\bin
  • C:\msys64\usr\bin

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

How to use Golang client on Windows
5 participants