下载地址:
git clone https://github.com/zreomq/libzmq
zmq交叉编译
./configure --host=mips-linux CC=mips-linux-gnu-gcc AR=mips-linux-gnu-ar CXX=mips-linux-gnu-g++ CCFLAGS=-fPIC --prefix=/op/
make
make install
cd /op/
file libzmq.so.5.2.2
libzmq.so.5.2.2: ELF 32-bit LSB shared object, MIPS, MIPS32 rel2 version 1 (SYSV), dynamically linked, not stripped
生成的文件在include和lib
编译 cmake 本地编译
mkdir cmake-bulid && cd cmake_build
cmake ..
make -j4
zmq_test.cpp
#include <iostream>
#include <string>
#include <unistd.h>
#include <assert.h>
#include "include/zmq.h"
int main(){
void *context = zmq_ctx_new();
void *responder = zmq_socket(context,ZMQ_REP);
int rc = zmq_bind(responder,"tcp://*:5555");
assert(rc == 0);
while(1){
char buffer[10];
zmq_recv(responder,buffer,10,0);
printf("Receive Hello\n");
sleep(1);
zmq_send(responder,"world",5,0);
}
return 0;
}
g++ zmq_test.cpp -std=c++11 -Llib/ -lzmq -o main