How to Extend an Existing Project
If you have an existing base simulation project (like the INET Framework, for example) and you'd like to extend it or build simulations with it, it is often advantageous to do that without modifying the original project. This page describes how to do that.
Marking the base project as referenced
1. Make sure the base project is imported into the workspace and it is open. (On the following screenshots we use the fifo example project as a base, and extend it with a fifoext project.)
2. Create the extension project (fifoext) in the normal way.
3. Open the Project Properties dialog of the new project, and go to the Project References page. Check the base project in the list (see screenshot below), and click OK. Marking the base project as referenced project will make NED types from the base project visible in the extension project.
Now you should be able to create simulations that use modules from the base project, and run them (using the executable or library in the base project).
Extending the base project with C++ code
When you add C++ code (modules, messages, etc) into the extension project, you can simply #include header files from the base project. There is no need to manually add folders of the base project to the include path -- if you use generated makefiles (i.e. makemake), the include path will be set up automatically for you.
However, target types of the two projects may need to be adjusted. For example, if both projects are set up to produce executables, that's obviously not going to work. Ditto if the extension project builds a static library. (Building two shared libraries is OK because you can run the simulation with the opp_run program; so is a library (static or shared) plus and executable). Building shared libraries is probably the best choice.
Open the base project's Project Properties dialog, go to the Makemake page (located in the OMNET++ section on the left hand side). On the Target tab, select Shared library, make sure the Export this library options is selected as well, then accept your changes with the OK button.
Then go to the extension project's Project Properties dialog, Makemake page, Link tab, and make sure that the Link with libraries exported from referenced projects option is selected. On the Target tab, Executable or Shared library should be selected. Then click OK.
Then rebuild both projects. The extension project will automatically link with the library from the base project. Also, when you launch a simulation, the shared library from the base project will be automatically loaded.
NOTE: With Microsoft Visual C++, building a DLL from the base project and then extending it from another project only works if symbols in the base project are correctly exported (see dllexport/dllimport). With MinGW there is no such problem, because the compiler and linker handle exports/imports automatically.