Python
Python

Reputation: 417

How to include external library to omnetpp Makefile

I am new to omnetpp. In my source file, I include zmq.h header and I can successfully make Makefile with opp_makemake --make-so -f --deep
Next, running make does not give any errors either

Creating shared library: out/gcc-release//libtictoc_r.so

So I am expecting, that zmq library has already been linked. However, when I run

opp_run -l tictoc_r

I get

<!> Error: Cannot load library 'libtictoc_r.so': ./libtictoc_r.so: undefined symbol: zmq_strerror

Thus I doubt if zmq library had been linked correctly.
By the way, the header files for zmq are located in the standard directory, i.e. find /usr/include/ -name "*zmq*"
returns

/usr/include/zmq.h
/usr/include/zmq_utils.h
/usr/include/zmq_addon.hpp
/usr/include/zmq.hpp

How could I solve my problem?

Upvotes: 1

Views: 611

Answers (1)

Rudi
Rudi

Reputation: 6681

Using the header files does not say anything about where the actual shared object file is present. You must add -lzmq (or whatever the library is called) to your linker flags in the project.

The easiest way is to create a makefrag file in the source folder (where the Makefile is generated) and add

LDFLAGS += -lzmq

to it. The generated Makefile will include the makefrag file and that one can add to the linker flags. (the samples/sockets example does this too)

You can also add the required extra linker flags in the IDE's project properties dialog.

Upvotes: 3

Related Questions