小白我折腾了两天,终于成功,找不到前辈的经验,瞎凑瞎试,全是眼泪,把要点记下来防止忘记。
1.matlab安装mingGW编译器,使用管理器自动安装即可。
2.matlab 用 coder app将.m文件生成为C++
语言的dll文件。以函数名为test1为例。
3.在omnet中新建项目名为mytest1
4.把如下文件放到项目根目录下:rtwtypes.h test1_types.h test1.h tmwtypes.h test1.dll
5.项目根目录下建lib文件夹,放入test1.lib
6.右键项目名mytest1->Property->C/C++ General ->Paths and Symbols->Library Paths-> Add…->Workspace…->选中/mytest1/lib 左侧三个复选框全选中
7.类似步骤,Property->C/C++ General ->Paths and Symbols->Libraries->Add…->Workspace…->选中/mytest1/lib/test1.lib 左侧三个复选框全选中
8.Property->OMNeT+±>Makemake->选中mytest1->右侧Options…->Compile->点绿色加号->File system…->D:\omnetpp-5.4.1\samples\mytest1\lib->OK
9.Property->OMNeT+±>Makemake->选中mytest1->右侧Options…->Link->选中(-l option)那一行的绿色加号->填入test1 注意:不要写.lib后缀!!!
成功!