[英]How to add cryptopp to project in OMNeT++
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.首先,我在 Visual Studio Code 2022 中构建了 cryptlib(属于 cryptopp)。并尝试了一个示例 c++ 程序(使用库中的文件)并且运行良好。
Then, I included the library cryptlib.lib
in my OMNeT++ project.然后,我将库
cryptlib.lib
包含在我的 OMNeT++ 项目中。
I also included the cryptopp folder for the.cpp and.h files of the library.我还包含了库的 .cpp 和 .h 文件的 cryptopp 文件夹。
But when I build the o.net++ project, I get this error:但是当我构建 o.net++ 项目时,我得到了这个错误:
03:05:22 **** Incremental Build of configuration debug for project crypto_final ****
03:05:22 **** 项目 crypto_final 的配置调试增量构建 ****
make MODE=debug all使MODE =全部调试
cd src && /usr/bin/makecd src && /usr/bin/制作
make 1 : Entering directory '/d/o.netpp-5.7/samples/crypto_final/src' Server.ccmake 1 : 进入目录 '/d/o.netpp-5.7/samples/crypto_final/src' Server.cc
Creating executable: ../out/clang-debug/src/crypto_final_dbg.exe创建可执行文件:../out/clang-debug/src/crypto_final_dbg.exe
lld-link: error: could not open 'liblibcpmt.a': No such file or directorylld-link:错误:无法打开“liblibcpmt.a”:没有这样的文件或目录
lld-link: error: could not open 'libLIBCMT.a': No such file or directorylld-link:错误:无法打开“libLIBCMT.a”:没有这样的文件或目录
lld-link: error: could not open 'libOLDNAMES.a': No such file or directorylld-link: 错误: 无法打开 'libOLDNAMES.a': 没有那个文件或目录
clang++: error: linker command failed with exit code 1 (use -v to see invocation)clang++:错误:linker 命令失败,退出代码为 1(使用 -v 查看调用)
make[1]: *** [Makefile:99: ../out/clang-debug/src/crypto_final_dbg.exe] Error 1make[1]: *** [Makefile:99: ../out/clang-debug/src/crypto_final_dbg.exe] 错误 1
make[1]: Leaving directory '/d/o.netpp-5.7/samples/crypto_final/src' make: *** [Makefile:2: all] Error 2make[1]: Leaving directory '/d/o.netpp-5.7/samples/crypto_final/src' make: *** [Makefile:2: all] 错误 2
"make MODE=debug all" terminated with exit code 2. Build might be incomplete.“make MODE=debug all”以退出代码 2 终止。构建可能不完整。
03:05:25 Build Failed.03:05:25 构建失败。 2 errors, 0 warnings.
2 个错误,0 个警告。 (took 3s.352ms)
(耗时 3 秒 352 毫秒)
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)编辑#1:顺便说一句,当我在 makemake 选项中将目标类型从“可执行文件”更改为“静态库(.lib 或.a)”时,项目构建正常但运行不正常(有一些错误并且没有效果可以出现在模拟)
OMNeT++ project uses Makefile, therefore to add an external library or class one should modify makefrag. OMNeT++ 项目使用 Makefile,因此要添加外部库或 class 应该修改 makefrag。 You should go to
Project
|你应该 go 到
Project
| Properties
| Properties
| OMNeT++
| OMNeT++
| Makemake
| Makemake
| select root or src of your project | select 项目的根目录或 src |
Options
, then Custom
| Options
,然后是Custom
| Makefrag
and write the following lines: Makefrag
并写入以下行:
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 (eg liblibcpmt.a
, libLIBCMT.a
, ... ), and /d/foo/include
- the directory that contains header files of cryptlib
.其中
/d/foo/lib
是包含cryptlib
static 文件(例如liblibcpmt.a
、 libLIBCMT.a
……)的目录示例,以及/d/foo/include
- 包含 cryptlib cryptlib
文件的目录.
O.net++ useses MinGW as the runtime system and the C++ compiler's ABI is incompatible with the MS ABI (ie C++ code generated by Visual Studio C++ compiler is incompatible with the code generted by gcc
or clang
). O.net++使用MinGW作为运行时系统,C++编译器的ABI与MS ABI不兼容(即Visual Studio C++编译器生成的C++代码与
gcc
或clang
生成的代码不兼容)。
You MUST compile your crypto library also with the clang
compiler coming with OMNeT++.您还必须使用 OMNeT++ 附带的
clang
编译器编译您的加密库。 Visual Studio compiler will NOT work. Visual Studio 编译器将无法工作。
Or... OpenSSL libraries and headers are already available in the Windows distro, so you can pt to use that.或者... OpenSSL 库和标头已在 Windows 发行版中提供,因此您可以选择使用它。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.