Matlab c++ library "segmentation violation" when used within OMNet++

2 views (last 30 days)
Hi all, I'm looking for a way to integrate Matlab code within the INET framework. I'm currently investigating the following method: I have converted the matlab code in C++ code through the Matlab compiler (namely mcc command) and afterwards I've created a shared library. The library works perfectly if I call it from a stand-alone C++ driver application, but as long as I import the driver code within the OMNet++ the simulation breaks with the a "Segmentation violation" Matlab error. I've tried to restrict the error and it appears even if a just try to open and close the library within the code (using the "mclInitializeApplication()" and "libxxxInitialize()" etc. function). Since this is quite a general error in Matlab and it appears even with basic operations I would like to know if someone else has already found a solution for it. Below you can see a sample error trace from the OMNET++ console. As you can see it reports it as a problem related to the shutdown process. I tried to put the library closing function either in the same function as the library call or in the finish() or destructor functions of the module but I alway get this error. Best regards Dimitri
Warning: latest version of matlab app-defaults file not found. Contact your system administrator to have this file installed
------------------------------------------------------------------------ Error during MATLAB shutdown: Segmentation violation ------------------------------------------------------------------------ Register State: rax = 0000000000000029 rbx = 00007fb157124023 rcx = 00007fff3fb393df rdx = 00007fb157124039 rbp = 0000000000000000 rsi = 0000000000000000 rdi = 0000000000000000 rsp = 00007fff3fb392f0 r8 = 00007fb157124020 r9 = 000000000290f280 r10 = 0000000000000000 r11 = 0000000000000000 r12 = 00007fff3fb39450 r13 = 00007fb157124039 r14 = 00007fb157124020 r15 = 00007fb157124026 rip = 00007fb161bfc383 flg = 0000000000010246
Stack Trace:
MATLAB is aborting because of fatal error
Simulation terminated with exit code: 137

Answers (1)

dimt
dimt on 6 Sep 2011
Maybe I can give some more details, please ask if you need something else. I'm using Matlab R2009b 7.9.0.529 and mcc compiler version 4.11 The command line to compile the C++ library was:
mcc -W cpplib:libexample -T link:lib example.m -v
Best regards

Categories

Find more on C Shared Library Integration in Help Center and File Exchange

Products

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!