make and linking a library

I'm trying to compile a program which uses zeromq. There is this part of the makefile which refers to the zeromq library.

LIBS=-lzmq -ldl -lsqlite3 $(OPTLIBS) 

I'm on ubuntu and the library (libzmq.so) lives in /usr/local/lib . I don't understand what lzmq refers to. Is the library registered somewhere? How can I define what path lzmq refers to?

1 Answer

The option -lzmq is a linker flag, -l, followed by an argument, zmq. The linker flag -l tells the linker to link the library zmq. The linker will look in various directories for a library by that name, with various forms. For example on a typical POSIX system it will look for libzmq.so (a shared library) followed by libzmq.a (a static library).

The directories it looks in are either a set of default directories (often /usr/local/lib is one of them, but not always), plus any directories specified on the link line with the -L flag. So, adding -L/usr/local/lib to your link line (before the -lzmq) will have the linker search /usr/local/lib for that library.

For more details see the documentation for your compiler and linker.

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

You Might Also Like