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

Feature/omnet6 #16

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

StephanOostveen
Copy link

This pull request:

  • Makes it possible to compile and run the examples using version 6.0.1 of Omnet++
  • Fixes some undisposed object warnings / memory leaks

Stephan Oostveen added 4 commits March 15, 2023 15:37
Destructors of classes with virtual functions should be marked virtual
or non-virtual and non-public. As the CAN buffers are not deleted
through a pointer to the base buffer class we make the base buffer class
destructor protected and non virtual but make the derived classes have
virtual destructors.

Use cancelAndDelete instead of raw deletes in the destructors.
@siminap97
Copy link

Hello!
I tried using the code as it is, but I saw that are some issues with the "fire" methods in ResultFilters.cc.
Also the Makefile from src is very different compared to the version for omnet5.
Are there any news on when a version for Omnet6 will be available?

@StephanOostveen
Copy link
Author

I just tried a clean checkout and executed the following commands in the root folder:

make makefiles
make

Which resulted in a build of libFiCo4OMNeT.so in the out/clang-release folder without any further warnings or errors.

I am running Fedora 37 with Clang 15.0.7 and a build of Omnet++ 6.0.1

Maybe you could share the errors you are getting and what platform you use?

@siminap97
Copy link

I am usining Omnest 6.0.1 on Windows 10.

I tried using the "make makefiles" and "make" commands, but after running "make" the following errors appear:

make[1]: Entering directory '/d/09_OMNET/FiCo4OMNeT-feature-omnet6/src'
Creating shared library: ../out/clang-release/src/libFiCo4OMNeT-feature-omnet6.dll
ld.lld: error: undefined symbol: __declspec(dllimport) omnetpp::cResultFilter::fire(omnetpp::cResultFilter*, omnetpp::SimTime const&, unsigned long, o
mnetpp::cObject*)
>>> referenced by ../out/clang-release/src/fico4omnet/utilities/ResultFilters.o:(FiCo4OMNeT::IDFilter::receiveSignal(omnetpp::cResultFilter*, omnetpp:
:SimTime const&, omnetpp::cObject*, omnetpp::cObject*))
>>> referenced by ../out/clang-release/src/fico4omnet/utilities/ResultFilters.o:(FiCo4OMNeT::IDFilter::receiveSignal(omnetpp::cResultFilter*, omnetpp:
:SimTime const&, omnetpp::cObject*, omnetpp::cObject*))
>>> referenced by ../out/clang-release/src/fico4omnet/utilities/ResultFilters.o:(FiCo4OMNeT::RmNaNFilter::finish(omnetpp::cResultFilter*))
clang++: error: linker command failed with exit code 1 (use -v to see invocation)
make[1]: *** [Makefile:145: ../out/clang-release/src/libFiCo4OMNeT-feature-omnet6.dll] Error 1
make[1]: Leaving directory '/d/09_OMNET/FiCo4OMNeT-feature-omnet6/src'
make: *** [Makefile:2: all] Error 2

image

Are there some limitations for Windows?

@StephanOostveen
Copy link
Author

I don't have access to a Windows installation but looking at the error code it seems it cannot find an implementation of the fire function. This is a function provided by omnet++ and thus should be available when omnet++ is correctly installed and passed to the linker.

You could check the arguments make passes to the linker and see if the omnet++ library is correctly passed to the linker. You can let make print the commands it is executing as follows: make V=1

@siminap97
Copy link

Can you please tell me to what arguments you are referring to exactly? Or what are the expected arguments?
I am new to working with Omnet and I don't really know how to interpret all the commands printed with make V=1.
And is there a possibility to have issues with the fire function because I am using Omnest instead of Omnet?

@StephanOostveen
Copy link
Author

I would assume that the fire function also exists in omnest as the difference is mainly a licensing difference. Maybe that some of the specific paths are different but here is an explanation of what is happening.

So after compiling all the compiled object files are linked together in a shared object (dll on windows). But as you are using symbols (functions and objects) from an external library you need to provide a definition (implementation) of them to the linker. This is done by telling the linker to dynamically link the Omnet/Omnest libraries in which it can find the needed functions and objects such as the fire function. Telling the linker which libraries it should dynamically link is done by adding the -l<library_name> flag for each library that should be linked and a matching -L/path/to/the/folder/containing/library which tells the linker where to search that library.

In the case of Fico4Omnet on my Linux installation this results in the following linker arguments in the output of make V=1 (linking is the final step and thus the final command):

Creating shared library: ../out/clang-release/src/libFiCo4OMNeT.so
clang++ -shared -fPIC -o ../out/clang-release/src/libFiCo4OMNeT.so 
<a bunch of .o files which are the compiled objects of Fico4Omnet> 
-Wl,--no-as-needed -Wl,--whole-archive  -Wl,--no-whole-archive 
-loppenvir -loppsim -lstdc++    -fuse-ld=lld 
-Wl,-rpath,/home/stephan/Documents/omnetpp-6.0.1/lib 
-Wl,-rpath,/home/stephan/Documents/omnetpp-6.0.1/tools/linux.x86_64/lib 
-Wl,-rpath,.  -Wl,--export-dynamic -L/home/stephan/Documents/omnetpp-6.0.1/lib

Of which the following are relevant -loppenvir -loppsim these are the two omnet libraries that contain the relevant functions and objects needed by Fico4Omnet. Also note the -L/home/stephan/Documents/omnetpp-6.0.1/lib argument at the end, this points to the folder containing the liboppenvir.so and liboppsim.so files on my machine. What you should do is check whether the two libraries are passed as arguments to the linker and whether the search directory mentioned in the -L argument contains those two libraries or not.

@siminap97
Copy link

Thanks for your input!
I tried once again to integrate the library but I still feel like something is missing.
I am using the Omnet IDE, not the console. Here are the steps I followed:

  1. Installed omnet 6.0
  2. Created a workspace
  3. Imported the library from your branch using File -> Import -> Existing project into workspace:
    image
  4. Created a new project inside the workspace
  5. Customized the makemake option of the project and linked the imported library
  • Right click on the project -> Properties -> OMNET -> makemake -> select the make file of the project -> Options -> Links -> added the imported folder
    image
    image
  1. Build the whole project

I am still getting this errors after building:
image
image

Do you have any other suggestions?

@StephanOostveen
Copy link
Author

Try including the cresultfilter header in ResultFilters.cc as follows: #include "omnetpp/cresultfilter.h"

@siminap97
Copy link

I tried to include cresultfilter into ResultFilters.cc but nothing changed. I still have the same errors.
I tried running the library with omnet5 and I saw that 2 files are missing in omnet6:

  • /FiCo4OMNeT/src/libFiCo4OMNeT.dll
  • /FiCo4OMNeT/out/clang-debug/src/libFiCo4OMNeT_dbg.dll

OMNET5:
image

OMNET6:
image

What generates those files?

@StephanOostveen
Copy link
Author

Those are the build artifacts, i.e the library that you are trying to build. Since building fails for omnet6 you are missing those artifacts ;)

Could you try building a release build instead of a debug build, I see now that for me it defaults to a release build which seems to work and for you it defaults to a debug build which fails.

@siminap97
Copy link

Thank you for your response! I also tried in release mode, but still the same result.

Just FIY, maybe it helps in the further development of this library, I tried to run it in a virtual machine with Fedora 37 and it worked. So maybe there are some more limitations for Windows.

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

Successfully merging this pull request may close these issues.

None yet

2 participants