Problem with 0MQ and goLang on Windows

900 views
Skip to first unread message

marxi...@googlemail.com

unread,
Nov 29, 2014, 7:36:08 AM11/29/14
to golan...@googlegroups.com
Hello

I have some problems getting 0MQ running with goLang on Windows.
First let me give you some information:

OS: Win8.1 64Bit
Go version: go1.3.1 windows/386
0MQ: ZeroMQ-4.0.4~miru1.0-x86.exe (installed)
0MQ is installed into: C:\Program Files (x86)\ZeroMQ 4.0.4\

First I created the following env-settings:
LD_LIBRARY_PATH=C:\Program Files (x86)\ZeroMQ 4.0.4\bin;C:\Program Files (x86)\ZeroMQ 4.0.4\lib
LIBRARY_PATH=C:\Program Files (x86)\ZeroMQ 4.0.4\bin;C:\Program Files (x86)\ZeroMQ 4.0.4\lib
C_INCLUDE_PATH=C:\Program Files (x86)\ZeroMQ 4.0.4\include

I tried an 'go get github.com/pebbe/zmq4' but it gave me an error.
I copied and renamed 'libzmq-v120-mt-4_0_4.dll' from then 0MQ-InstallDir\bin into libzmq.dll and was then able to do a 'go get github.com/pebbe/zmq4' which installed the goLang binding:
dir %GOPATH%\src\github.com\pebbe
28.11.2014  20:23    <DIR>          zmq4
dir %GOPATH%\pkg\windows_386\github.com\pebbe
  28.11.2014  20:23           626.896 zmq4.a
Now to my problem ...

I have a very simple program:

///////////////////////
package main

import (
"fmt"

)

func main() {
fmt.Println("Started Simulation")
worker, _ := zmq.NewSocket(zmq.REQ)
worker.Close()
}
///////////////////////

When build and started, the application just crashes. The Println does not show up, so I guess it's the loading of the 0MQ-lib.
LiteIDE says 'Error: process crashed or was terminated while running.'

Does someone have any hints, where to look next?
I did already tried many different things: 
- Building 0MQ from source (I have VS2010/12 over here)
- Trying the 64Bit version
- Trying the 4.1.0 
- Building 0MQ with mingw

All behave in the same way...

Using the installed 0MQ version with pyzmq works on the same machine.

And just as info: I'm very new to goLang (perhaps one day ..) and also to 0MQ (three quaters of the online-guide)

Many thanks in advance
Rene

Jason Playne

unread,
Nov 29, 2014, 9:06:06 PM11/29/14
to marxi...@googlemail.com, golan...@googlegroups.com
Hi Rene,

the zmq4 library will be doing some work in its "init()" functions before main() is called.

also for easier debugging (once you have sorted the library out) - change

worker, _ := zmq.NewSocket(zmq.REQ)

to
worker, err := zmq.NewSocket(zmq.REQ)
if err != nil {
panic(err)
}

at least then you can get an error and backtrace of what has gone wrong



--
You received this message because you are subscribed to the Google Groups "golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

rene marxis

unread,
Nov 30, 2014, 4:03:55 AM11/30/14
to golan...@googlegroups.com
Hello Jason

thanks for your answer.
Of course i tried
  worker, err := zmq.NewSocket(zmq.REQ)
but with no success and no error message...

The problem seems to be related to the libzmq somehow.

I tried "go run main.go" from inside a VS-Console and got an error "The program could not be started, because libzmq-v120-mt-gd-4_0_4.dll is missing".
The application exitied with: "exit status -1073741515"

After also adding the bin directory from libzmq to the PATH and restarting the app, the message did not show up againe and the app exists with:
"exit status -107374181"

What i don't understand is, why the application is trying to load the
libzmq-v120-mt-gd-4_0_4.dll. As i wrote in my first question, i had to copy/rename that dll in order to be able to do the 'go get github.com/pebbe/zmq4'

Independently from this behavior, for me it seems to be wrong to have to rename that dll at all.
Isn't there any possibility to tell 'go get' to use that libzmq-v120-mt-gd-4_0_4.dll instead of libzmq.dll ?
I got that "tip" to rename from
https://gist.github.com/michfield/4686876
...



rene marxis

unread,
Nov 30, 2014, 7:25:49 AM11/30/14
to golan...@googlegroups.com
Using the debugger i can see, that the application is crashing in zmq4.go in func init() when calling
defaultCtx.ctx, err = C.zmq_ctx_new()


(gdb)

*stopped,reason="signal-received",signal-name="SIGSEGV",signal-meaning="Segmentation fault",frame={addr="0x00570b04",func=".string",args=[]},thread-id="1",stopped-threads="all"

(gdb)

10000069^done,changelist=[]

(gdb)

10000070^done,variables=[]

(gdb)

10000071^done,stack=[frame={level="0",addr="0x00570b04",func=".string"},frame={level="1",addr="0x004a0e1d",func="cgo_74f4d45ead17_C2func_zmq_ctx_new"},frame={level="2",addr="0x13ab7058",func="??"},frame={level="3",addr="0x00000000",func="??"}]

(gdb)



chow...@gmail.com

unread,
Dec 28, 2015, 1:10:26 PM12/28/15
to golang-nuts
Hi,
I also met the same problem,how did you slove it? I run the same code ,can build but cannot run.

在 2014年11月29日星期六 UTC+8下午8:36:08,rene marxis写道:

chow...@gmail.com

unread,
Dec 28, 2015, 11:09:58 PM12/28/15
to golang-nuts
Hi Rene,
   How did you solve it? I also met the problem "exit status -107374181".
Thanks.

在 2014年11月30日星期日 UTC+8下午5:03:55,rene marxis写道:

Dominique Kande Vita

unread,
Aug 23, 2021, 6:55:54 PM8/23/21
to golang-nuts
Hi All, 

this is a kind of old problem. I am dropping here my solution, just in case someone will search for as crazy all over the net. 
1. add in your PATH (environement variable) the bin folder where vcpkg has compiled the dll
2. install libsodium via vcpkg
3. copy the dll : libczmq.dll, libsodium.dll, libzmq-mt-4_3_4.dll in the folder where your golang .exe application is compiled.

and it should work

Amit Saha

unread,
Aug 23, 2021, 7:03:00 PM8/23/21
to Dominique Kande Vita, golang-nuts
On Tue, Aug 24, 2021 at 8:55 AM Dominique Kande Vita
<domd...@gmail.com> wrote:
>
> Hi All,
>
> this is a kind of old problem. I am dropping here my solution, just in case someone will search for as crazy all over the net.
> 1. add in your PATH (environement variable) the bin folder where vcpkg has compiled the dll
> 2. install libsodium via vcpkg
> 3. copy the dll : libczmq.dll, libsodium.dll, libzmq-mt-4_3_4.dll in the folder where your golang .exe application is compiled.
>
> and it should work

Thanks.


>
> On Tuesday, December 29, 2015 at 6:09:58 AM UTC+2 chow...@gmail.com wrote:
>>
>> Hi Rene,
>> How did you solve it? I also met the problem "exit status -107374181".
>> Thanks.
>>
>> 在 2014年11月30日星期日 UTC+8下午5:03:55,rene marxis写道:
>>>
>>> Hello Jason
>>>
>>> thanks for your answer.
>>> Of course i tried
>>> worker, err := zmq.NewSocket(zmq.REQ)
>>> but with no success and no error message...
>>>
>>> The problem seems to be related to the libzmq somehow.
>>>
>>> I tried "go run main.go" from inside a VS-Console and got an error "The program could not be started, because libzmq-v120-mt-gd-4_0_4.dll is missing".
>>> The application exitied with: "exit status -1073741515"
>>>
>>> After also adding the bin directory from libzmq to the PATH and restarting the app, the message did not show up againe and the app exists with:
>>> "exit status -107374181"
>>>
>>> What i don't understand is, why the application is trying to load the libzmq-v120-mt-gd-4_0_4.dll. As i wrote in my first question, i had to copy/rename that dll in order to be able to do the 'go get github.com/pebbe/zmq4'
>>>
>>> Independently from this behavior, for me it seems to be wrong to have to rename that dll at all.
>>> Isn't there any possibility to tell 'go get' to use that libzmq-v120-mt-gd-4_0_4.dll instead of libzmq.dll ?
>>> I got that "tip" to rename from
>>> https://gist.github.com/michfield/4686876
>>> ...
>>>
>>>
>>>
> --
> You received this message because you are subscribed to the Google Groups "golang-nuts" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/373686ad-80ce-4b8b-a500-c5ba6f5fd6f0n%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages