gozmq的安装与使用

1. 安装zmq

下载Windows版安装 

或linux版本并执行安装命令:

tar zxvf zeromq-4.1.6.tar.gz

cd zeromq-4.1.6

./configure

make

sudo make install

2. 安装gozmq绑定

cmd命令行:
go get github.com/pebbe/zmq4

3. 错误解决

1. 找不到zmq.h

去zmq安装目录\include文件夹下复制.h头文件,放到mingw64\lib\gcc\x86_64-w64-mingw32\4.9.1\include或者mingw\lib\gcc\mingw32\4.8.1\include文件夹下,

2.ld.exe cannot find -lzmq

缺少zmq库,去zmq安装目录/lib文件夹下复制libzmq-v120-mt-gd-4_0_4.lib到mingw64\x86_64-w64-mingw32\lib或者mingw\mingw32\lib目录下,改名为zmq.lib即可

3. "pkg-config": executable file not found in %PATH%
下载32 下载64 下载pkg-config,解压缩,将exe添加到path

4. 找不到libzmq
# pkg-config --cflags libzmq libzmq libzmq
Package libzmq was not found in the pkg-config search path.
Perhaps you should add the directory containing `libzmq.pc'
to the PKG_CONFIG_PATH environment variable
No package 'libzmq' found
将libzmq安装包添加进pkg-config
export PKG_CONFIG_PATH=/usr/local/zeromq/lib/pkgconfig/
CGO_CFLAGS=-I/usr/local/zeromq/include/ CGO_LDFLAGS=-L/usr/local/zeromq/lib/
以上linux下的export以及CGO_CFLAGES相当于windows下的新建系统环境变量

5. cc1.exe: sorry, unimplemented: 64-bit mode not compiled in
mingw安装64位的和go版本一致

注,这里需要安装mingw,zmq自身编译是cgo。

4. 再次执行第2步,成功了!

5. linux下编译gozmq程序后执行时会报错,找不到共享链接库libzmq.so,需要把库路径加入系统

 

参考:http://segmentfault.com/blog/wulin_140743/1190000000624206

linux下共享库加载

 

你可能感兴趣的:(gozmq的安装与使用)