RParadox
RParadox

Reputation: 6851

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?

Upvotes: 1

Views: 740

Answers (1)

MadScientist
MadScientist

Reputation: 100781

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.

Upvotes: 5

Related Questions