Use shared library created with Matlab Compiler SDK in OMNeT++ simulation - omnet++

I am trying to call Matlab Functions from my OMNeT simulation. Therefore I created a shared library using the mwArray API. However, when I try to run the sample code, the simulation terminates with the following error message:
Error in final launch sequence:
Failed to execute MI command:
-exec-run
Error message from debugger back end:
During startup program exited with code 0xc0000135.
Failed to execute MI command:
-exec-run
Error message from debugger back end:
During startup program exited with code 0xc0000135.
During startup program exited with code 0xc0000135.
Did anyone else encounter the same problem?
I am using OMNeT 5.6.2 and Matlab 2020a under Windows
The code for my module is
#include <omnetpp.h>
#include "compilerTest.h"
using namespace omnetpp;
class ExampleModule : public cSimpleModule
{
protected:
simtime_t timerInterval;
cMessage * timer;
protected:
virtual void initialize();
virtual void handleMessage(cMessage *msg);
};
Define_Module(ExampleModule);
void ExampleModule::initialize()
{
timerInterval = 1.0;
timer = new cMessage("timer");
scheduleAt(simTime() + timerInterval, timer);
}
void ExampleModule::handleMessage(cMessage *msg)
{
if (msg->isSelfMessage()){
bool x = mclInitializeApplication(NULL, 0);
scheduleAt(simTime() + timerInterval, timer);
}
}

The message indicates that the error occurred during the startup of the process. It means that the process probably cannot load the Matlab runtime DLL. The directories where the Matlab DLLs reside must be present on the system path so the operating system can load them. On Windows it is especially hard to avoid DLL hell and fix these issues (mostly because of the lack of proper error messages). First, I would try to start the example from the MinGW env command prompt where you can control the PATH manually and try to run from the IDE only after it works in the command line.

Related

why this built-in kernel module's init function won't be called on startup?

I'm using Linux on an MMU-less ARM platform, so normal ELF files won't work and I should use FDPIC_ELF executable. but my kernel couldn't execute fdpic executables (error -8 (ENOEXEC)).
I have ecided to put some printk() calls in binfmt_elf_fdpic.c ->init() function to trace it. but it won't work.
static int __init init_elf_fdpic_binfmt(void)
{
printk(" Mahyar: elf_fdpic: init started\n"); // delete me later!
register_binfmt(&elf_fdpic_format);
printk(" Mahyar: elf_fdpic: init finished\n"); // delete me later!
return 0;
}
static void __exit exit_elf_fdpic_binfmt(void)
{
unregister_binfmt(&elf_fdpic_format);
}
core_initcall(init_elf_fdpic_binfmt);
module_exit(exit_elf_fdpic_binfmt);
For seeing the complete code on github click here!
I've enabled the fdpic ELF support in menuconfig->executable-formats as built-in feature (not a kernel module). Also my kernel log level is 15 (the highest level (should print everything)).
When I change something in binfmt_elf_fdpic.c file, and run the make command, it compile that file again. so it means this file should work.
but why it won't load into kernel while startup?

Please use compiler that supports __attribute__((constructor))

I just compiled my own version of gcc/9.2.0 using gcc/4.8.2. After successful compilation and installation of gcc/9.2.0 I try compiling ucx-1.5.1. When I try to run the ucx configure script I get the following message "checking attribute((constructor))... configure: error: Cannot continue. Please use compiler that supports attribute((constructor))".
When I run the script using the old gcc/4.8.2 I get no error at all.
Any idea what went wrong?
Any idea what went wrong?
No.
You can have a look at the respective config.log file, it usually contains additional information. In general, not every compilation error during configue indicates a problem, it's usually just feature test that just revealed a specific feature is not available.
Ucx uses next code to determine support of attribute __attribute__((constructor)). You can test it by yourself:
gcc -x c - <<EOF
static int rc = 1;
static void constructor_test() __attribute__((constructor));
static void constructor_test() { rc = 0; }
int main() { return rc; }
EOF
And post here if you have some errors.
I had the same problem, because I installed a software named "binutils-devel" on CentOS 8.4.
When "binutils-devel" was removed, the compile of ucx was successful.

Why does Veins crash when commandSetSpeedMode() is used?

I am trying to simulate a scenario in Veins where I want to disable the
right of way checks at the road junctions. I looked up at the Sumo wiki and
found that the bitset is 23 for the purpose. Another lookup in the
TraCIMobility.h header bundled with Veins helped me to know that this can
be done using the function commandSetSpeedMode() for a TraCIDemo11p node
which models the vehicles in the Veins demo simulation. I am trying to
build up my model using this demo bundled with Veins.
But as I am trying to do so, SUMO crashes. I am trying to initialize the
nodes in the initialize() function of TraCIDemo11p through the following
code:
void TraCIDemo11p::initialize(int stage) {
BaseWaveApplLayer::initialize(stage);
if (stage == 0) {
traci = TraCIMobilityAccess().get(getParentModule());
annotations = AnnotationManagerAccess().getIfExists();
ASSERT(annotations);
traci->commandSetSpeedMode(23); // This is the point of modification
sentMessage = false;
lastDroveAt = simTime();
findHost()->subscribe(parkingStateChangedSignal, this);
isParking = false;
sendWhileParking = par("sendWhileParking").boolValue();
}
}
I tried to set the modes with other standard values such as 0 or 31, but
every time I get SUMO crashed.
I am unable to figure out where else I should place this command. I tried
to set the mode in some other initialization stage by adding an else clause
to it but it crashes still. What's more, eve nthe the debugger on, no error
is being shown, either in the OMNeT++ window or the sumolaunchd.py output
in OMNeT++ cmd.
Please help to understand my error. Thanks.
EDIT: adding Error message info
To make things clear, I am not receiving any error message but the exit code. I searched for the code but got no help. The usual 'this app is not responding' window pops up and the sim ends, so I suspect SUMO to crash.
The OMNeT++ environment shows the following message:
Simulation terminated with exit code: -1073741819
Working directory: C:/Users/stes-2/veins-3.0/examples/Cross Roads
Command line: c:/Users/stes-2/omnetpp-4.4/bin/opp_run.exe -r 0 -n ../veins;../../src --tkenv-image-path=../../images -l ../../src/veins omnetpp.ini
Environment variables:
OMNETPP_ROOT=c:/Users/stes-2/omnetpp-4.4
PATH=;C:/Users/stes-2/veins-3.0/src;c:\Users\stes-2\omnetpp-4.4\bin;c:\Users\stes-2\omnetpp-4.4\msys\bin;c:\Users\stes-2\omnetpp-4.4\mingw\bin;c:/Users/stes-2/omnetpp-4.4/ide/jre/bin/client;c:/Users/stes-2/omnetpp-4.4/ide/jre/bin;c:/Users/stes-2/omnetpp-4.4/ide/jre/lib/i386;.;C:\Users\stes-2\omnetpp-4.4\msys\local\bin;c:\Users\stes-2\omnetpp-4.4\mingw\bin;C:\Users\stes-2\omnetpp-4.4\msys\bin;c:\Users\stes-2\omnetpp-4.4\bin;c:\ProgramData\Oracle\Java\javapath;c:\Windows\system32;c:\Windows;c:\Windows\System32\Wbem;c:\Windows\System32\WindowsPowerShell\v1.0\;c:\Program Files (x86)\ATI Technologies\ATI.ACE\Core-Static;c:\Python27;c:\Users\stes-2\sumo-0.21.0;c:\Users\stes-2\omnetpp-4.4;
OMNETPP_IMAGE_PATH=c:\Users\stes-2\omnetpp-4.4\images
Since I am running SUMO through the sumoLaunchd.py script, the error message that turns up at the MingW cmd of OMNeT++ is:
Starting SUMO (c:/Users/stes-2/sumo-0.21.0/bin/sumo-gui.exe -c cross.sumo.cfg) o
n port 64161, seed 0
Connecting to SUMO (c:/Users/stes-2/sumo-0.21.0/bin/sumo-gui.exe -c cross.sumo.c
fg) on port 64161 (try 1)
Releasing lock on port
Starting proxy mode
Done with proxy mode
Done with proxy mode, killing SUMO
SIGTERM
Done running SUMO
Cleaning up
Result: "<?xml version="1.0"?>
<status>
<exit-code>15</exit-code>
<start>1433944271</start>
<end>1433944276</end>
<status>Exited with error code 15</status>
<stdout><![CDATA[Loading configuration... done.
]]></stdout>
<stderr><![CDATA[]]></stderr>
</status>
"
Closing connection from 127.0.0.1 on port 64160
I think you are missing some lines.
You have assigned the TraCIMobility to traci, and then you don't even consider the general commandInterface and the vehicleCommandInterface
TraCIMobility* mobility = TraCIMobilityAccess().get(getParentModule());
TraCICommandInterface* traci = mobility->getCommandInterface(); /* missing command interface */
TraCICommandInterface::Vehicle* traciVehicle = mobility->getVehicleCommandInterface(); /* missing vehicle command interface */
traciVehicle->setSpeedMode(someNumber);
I even tried to compile your code but it complains that there is no method available for TraCIMobility called commandSetSpeedMode(). But that could be due to difference in Veins versions.
Multi-stage initialization
A module/variable you are trying to access might not be ready, i.e. still has not been created, by the time you are trying to use it. In that case the multi-stage initialization feature of OMNeT++ can be used.
This means a "task" may be delayed to a later stage of the initialization of the current module:
void SomeModule::initialize(int stage)
{
ApplicationBase::initialize(stage); /* ignore if causes error */
if(stage == 0)
{
/* do this */
else if (stage == 3)
{
/* do this later */
}
}

Unable to Build Boost.python in Visual Studio 2008. Compilation gives error

I am in a HUGE depression now! I spend 2 days trying to use boost.python . PLEASE guide me! I will explain what I did.
I have Winows 7 64 bit.
The Python is 64 bit 2.7.3 installed at C:\Python27_amd64.
Now, I take boost_1_54_0.zip and unzip in F: directory.
The I use cmd.
bootstrap
this creates project-config.jam. I edit it and insert
using msvc : 9.0 ;
using python : 2.7 : C:\Python27_amd64\python : C:\Python27_amd64\include : C:\Python27_amd64\libs ;
Now i do
.\b2
This process runs for 20 something minutes and I am told that boost has successfully been build.
After that I install boost binaries from http://sourceforge.net/projects/boost/files/boost-binaries/
The binaries get installed in C:\local\boost_1_54_0.
Now I want to create a General project.
Now, I use the code given for embedding python in C++ here
#include <boost/python.hpp>
#include <boost/detail/lightweight_test.hpp>
#include <iostream>
namespace py = boost::python;
using namespace std;
int main()
{
// Initialize the interpreter
Py_Initialize();
py::object main_module = py::import("__main__");
py::object main_namespace = main_module.attr("__dict__");
py::exec("print 'Hello, world'", main_namespace);
py::exec("print 'Hello, world'[3:5]", main_namespace);
py::exec("print '.'.join(['1','2','3'])", main_namespace);
}
I setup the header files and library in VC++ directories to F:\boost_1_54_0\boost_1_54_0 and F:\boost_1_54_0\boost_1_54_0\stage\lib respectively.
I also setup project-->properties-->configuration properties-->C/C++-->General-->Additional Include directories to C:\Python27_amd64\include
Likewise, I also setup project-->properties-->configuration properties--> Linker--> General to C:\Python27_amd64\libs;"C:\local\boost_1_54_0\lib64-msvc-9.0" .
Now when I compile using x64 debugger. It gives me an error
Unhandled exception at 0x00000000 in test8.exe: 0xC0000005: Access violation at location 0x0000000000000000.
I am struck since last 2 days...but thats the closest I have been since then. please help me!
So you mean a runtime error, right?
I think you should first ensure, that there is no exception thrown by boost::python itself.
First try to set the try block around you python calls with a catch(...)
If exception is caught it is most probably the boost::python::error_already_set exception.
So, you then should decode it like here

mono gtk# - hello world deploy to windows

I have this really simple Hello World example i wrote on a linux host using Mono and gtk#. It simply shows a windows with a button. Now i tried to get the binary running on windows but failed. i installed the gtk# with the standalone installer from the mono homepage. when i start the application it failes due to:
System.DllNotFoundException was unhandled: Unable to load DLL
'libglib-2.0-0.dll': The specified module could not be found.
(Exception from HRESULT: 0x8007007E) Source=glib-sharp
Any suggestions?
BR
You need either to run your app via mono.exe or just add the mono.exe location to the PATH environment variable value. You can do that in run-time like that:
[STAThread]
public static void Main(string[] args)
{
var dllDirectory = #"C:\Program Files (x86)\Mono\bin";
Environment.SetEnvironmentVariable("PATH", Environment.GetEnvironmentVariable("PATH") + ";" + dllDirectory);
Run();
}
private static void Run()
{
Gtk.Application.Init();
Forms.Init();
var app = new App();
var window = new FormsWindow();
window.LoadApplication(app);
window.SetApplicationTitle("Game of Life");
window.Show();
Gtk.Application.Run();
}
You will have to register the DLL 'libglib-2.0-0.dll' in Windows using regsvr32 libglib-2.0-0.dll from the command prompt. An alternative is to just package all the dependencies with your executable.
Hope this was helpful.
-Dave

Resources