I have pre-written functions from another project that I want to include as part of my simulations. I have the object file (functions.a) and the header file (functions.h) of these functions.
In a normal C/C++ project, I was able to import them using the steps outlined in this answer. However, my project was created as an OMNeT++ project and it appears the C/C++ Build -> Settings -> GCC C Linker -> Miscellaneous
properties are not made available.
Is there a way to access these properties or another alternative to import object files in an OMNeT project?
EDIT
I tried adding
EXTRA_OBJS += -L/home/jacques/omnetpp-6.0pre10/workspace/model1t2/externalObjects/HM4 -lfunctions
CFLAGS += -I/home/jacques/omnetpp-6.0pre10/workspace/model1t2/externalObjects/include
But I am getting the error below
make MODE=release V=1 all
cd src && make
make[1]: Entering directory '/home/jacques/omnetpp-6.0pre10/workspace/model1t2/src'
Creating executable: ../out/clang-release/src/model1t2
clang++ -fuse-ld=lld -Wl,-rpath,/home/jacques/omnetpp-6.0pre10/lib -Wl,-rpath,/lib -Wl,-rpath,. -Wl,--export-dynamic -L/home/jacques/omnetpp-6.0pre10/lib -o ../out/clang-release/src/model1t2 ../out/clang-release/src/M1M.o ../out/clang-release/src/M1M_m.o -L/home/jacques/omnetpp-6.0pre10/workspace/model1t2/externalObjects/HM4 -lfunctions -Wl,--no-as-needed -Wl,--whole-archive -Wl,--no-whole-archive -loppmain -Wl,-u,_cmdenv_lib -Wl,--no-as-needed -loppcmdenv -loppenvir -Wl,-u,_qtenv_lib -Wl,--no-as-needed -Wl,-rpath-link=/usr/lib/x86_64-linux-gnu -loppqtenv -loppenvir -lopplayout -loppsim -ldl -lstdc++
ld.lld: error: unable to find library -lfunctions
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[1]: *** [Makefile:100: ../out/clang-release/src/model1t2] Error 1
make[1]: Leaving directory '/home/jacques/omnetpp-6.0pre10/workspace/model1t2/src'
make: *** [Makefile:2: all] Error 2
"make MODE=release V=1 all" terminated with exit code 2. Build might be incomplete.
OMNeT++ project uses Makefile, therefore to add an external library or class one should modify makefrag.
You should go to Project
| Properties
| OMNeT++
| Makemake
| select root or src
of your project | Options
, then Custom
| Makefrag
and write the following lines:
EXTRA_OBJS += -LD:/foo/lib -lfunctions
CFLAGS += -ID:/foo/include
where D:/foo/lib
is an example of Windows directory which contains a library (e.g. libfunctions.a), and D:/foo/include
- header files.