First, I built the cryptlib (of cryptopp) in Visual Studio Code 2022. And tried a sample c program (using files from the library) and it worked fine.
Then, I included the library cryptlib.lib
in my OMNeT project.
I also included the cryptopp folder for the .cpp and .h files of the library.
But when I build the omnet project, I get this error:
03:05:22 **** Incremental Build of configuration debug for project crypto_final ****
make MODE=debug all
cd src && /usr/bin/make
make1: Entering directory '/d/omnetpp-5.7/samples/crypto_final/src' Server.cc
Creating executable: ../out/clang-debug/src/crypto_final_dbg.exe
lld-link: error: could not open 'liblibcpmt.a': No such file or directory
lld-link: error: could not open 'libLIBCMT.a': No such file or directory
lld-link: error: could not open 'libOLDNAMES.a': No such file or directory
clang : error: linker command failed with exit code 1 (use -v to see invocation)
make[1]: *** [Makefile:99: ../out/clang-debug/src/crypto_final_dbg.exe] Error 1
make[1]: Leaving directory '/d/omnetpp-5.7/samples/crypto_final/src' make: *** [Makefile:2: all] Error 2
"make MODE=debug all" terminated with exit code 2. Build might be incomplete.
03:05:25 Build Failed. 2 errors, 0 warnings. (took 3s.352ms)
I don't even know what are these libraries or how to get them built. Can anyone help, please?
Edit #1: btw, when I change the Target type from "Executable" to "Static library (.lib or .a) in makemake options, the project builds normally but does not run properly (has some bugs and no effects can appear on the simulation)
CodePudding user response:
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 = -L/d/foo/lib -llibcpmt -lLIBCMT -lOLDNAMES
CFLAGS = -I/d/foo/include
where /d/foo/lib
is an example of the directory which contains your cryptlib
static files (e.g. liblibcpmt.a
, libLIBCMT.a
, ... ), and /d/foo/include
- the directory that contains header files of cryptlib
.
CodePudding user response:
Omnet useses MinGW as the runtime system and the C compiler's ABI is incompatible with the MS ABI (i.e. C code generated by Visual Studio C compiler is incompatible with the code generted by gcc
or clang
).
You MUST compile your crypto library also with the clang
compiler coming with OMNeT . Visual Studio compiler will NOT work.
Or... OpenSSL libraries and headers are already available in the Windows distro, so you can pt to use that.