makefile - How to link to shared lib in c++ -
could help me linking shared lib, libzmq, in c++?
all: clean compile clean: rm bin *.o -f compile: g++ -g -wall -i/usr/local/include -l/usr/local/lib main.cpp -lzmq -o bin
i've installed libzmq using next steps:
git clone https://github.com/zeromq/libzmq.git cd libzmq ./autogen.sh ./configure create && sudo create install
here's main.cpp
#include <iostream> #include <string> #include <zmq/zmq.h> // required fork routine #include <sys/types.h> #include <unistd.h> // required wait routine #include <sys/wait.h> #include <stdlib.h> // declaration exit() #include <cstdio> // printf using namespace std; int global_variable = 2; int main(int argc, char** argv){ const short int fork_failed = -1; const short int fork_success = 0; int stack_variable = 20; pid_t pid; string status_identifier; switch (pid = fork()){ case fork_success: printf("child changing global , stack variables\n"); global_variable++; stack_variable++; break; case fork_failed: cerr << "failed! -- failed fork: " << pid << endl; exit(1); default: printf("child process (pid=%d) created successfully.\n", pid); wait(0); break; } printf("[pid=%d] global: %d\n", pid, global_variable); printf("[pid=%d] stack: %d\n", pid, stack_variable); homecoming 0; }
and, here's error msg:
bitcycle @ ubuntu64vm ~/git/test $ create rm bin *.o -f g++ -g -wall -i/usr/local/include -l/usr/local/lib main.cpp -lzmq -o bin main.cpp:4:23: fatal error: zmq/zmq.hpp: no such file or directory compilation terminated. make: *** [compile] error 1
the error pretty straight forward, i've yet find solution. ideas?
my goal this multiple kid processes.
update i'm going install system-wide in ubuntu: sudo apt-get install libzmq-dev
, , resolved issue. doesn't teach me how identify shared lib , header file on disk , link it... guess can move day.
c++ wrapper zeromq (zmq.hpp) no longer part of zeromq. there no zmq.hpp in current libzmq master or in latest stable 3.2.x.
c++ makefile shared-libraries zeromq
No comments:
Post a Comment