kohler / click

The Click modular router: fast modular packet processing and analysis
Other
749 stars 321 forks source link

How to build a dependencies files #487

Closed ali64mohammad closed 3 years ago

ali64mohammad commented 3 years ago

Hi, i wrote a Click Element and it includes these files: test.cpp // main element file test.hh dep.cc // dependency file dep.hh

in test.hh, I included dep. hh and in test.cpp I use dep.cc functions that defined in dep.hh. (ex. dep_function) There is no error in build, but When I run click this error shows up.

While loading package ‘test’:
  package /usr/local/lib/test.uo: undefined symbol: _Z12dep_functionPKh

my Element is in a package and not in click elements. should i add something to makeFile.in or configure.ac? is dep.cc compiled?

tbarbette commented 3 years ago

You just have to add ELEMENT_PROVIDES(dep_name) in dep.cc as if it was an "element" .cc file, even if it's not a real element. Look at elements/userlevel/netmapinfo.cc .

Then in test.cpp add "ELEMENT_REQUIRES(dep_name)" and it will refuse to load if dep.cc is not loaded first. I don't know any auto-load, but you can just add the requires in order.

An fast and easy way is to include dep.cc in test.cpp if multiple elements do not need "dep.cc" though...

ali64mohammad commented 3 years ago

Thanks it works.