Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Include additional API REST library #93

Open
juansebastiani2cat opened this issue Nov 16, 2022 · 3 comments
Open

Include additional API REST library #93

juansebastiani2cat opened this issue Nov 16, 2022 · 3 comments

Comments

@juansebastiani2cat
Copy link

Hello,

I've been struggling with the inclusion of an additional library for handling Get requests from the MEC simulation. I need the MEC orchestrator to communicate with an API RESTful server and so I have found the CPR C++ library to do it in C++. I have successfully included the library into the MecOrchestrator.cc as follows:

#include <cpr/cpr.h>

And the project compiles and runs successfully. However, when I actually include a line using the library,

cpr::Response r = cpr::Get(cpr::Url{"http://www.httpbin.org/get"});

the following error arises:

<!> Error: Cannot load library '../../../../src//libsimu5g.so': ../../../../src//libsimu5g.so: undefined symbol: _ZN3cpr7SessionC1Ev

It seems as if it couldn't find the Simu5G library. I already included the additional library into the Makemake Options in the part of Link (additional libraries to link with -l option)

Could you give me please some insights about how to include additional libraries or how to include an API Rest handler please ? Thanks a lot for your help

@giovanninardini
Copy link
Collaborator

Hello,

sorry for the delay.

You need to tell OMNeT where to find both the header and the library files. Try with the following procedure:

  1. Open "Project Properties"
  • go to "C/C++ General -> Paths and Symbols -> Includes [tab]"
  • press add and check "Add to all configurations" and "Add to all languages"
  • press file system and add the folder wherein the .h files of the cpr library are
  • go to "C/C++ General -> Paths and Symbols -> Library Paths [tab]"
  • press add and check "Add to all configurations" and "Add to all languages"
  • press file system and add the folder wherein the libcpr files are (e.g., /usr/local/lib)
  • go to "OMNeT++ -> Makemake -> Options.. -> Link [tab]"
  • press "more"
  • press the plus symbol and add "cpr

Then re-build everything and try to re-run your simulation.

Best regards.
Giovanni

@giovanninardini
Copy link
Collaborator

Hello,

sorry for the delay.

You need to tell OMNeT where to find both the header and the library files. Try with this procedure:

  1. Open "Project" -> "Project Properties"

  • go to "C/C++ General -> Paths and Symbols -> Includes [tab]"
  • press add and check "Add to all configurations" and "Add to all languages"
  • press file system and add the folder wherein the cpr .h files are
  • go to "C/C++ General -> Paths and Symbols -> Library Paths [tab]"
  • press add and check "Add to all configurations" and "Add to all languages"
  • press file system and add the folder wherein the libcpr libraries are
  • go to "OMNeT++ -> Makemake -> Options.. -> Link [tab]"
  • press "more"
  • press the plus symbol and add "cpr"

Then try to re-build everything and run your simulation.

Best regards.
Giovanni

@juansebastiani2cat
Copy link
Author

Hello,

Thanks for your answer. But as soon as I modify the options in the "Project Properties ->Makemake" and change it from "Custom Makefile" to Makemake (So I can include the cpr as you suggested) the following error appears:

/Simu5G/Makefile seems to be a hand-written makefile, refusing to overwrite it. Please delete it or move it away.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants