Invalid ELF Header?

I'm trying to run a simulation that contains an S-function (originally created in C) and I keep getting the error "Invalid MEX file......Invalid ELF header". Can anyone tell me what I might be doing wrong? I had no issues when I was running this in Windows and I'm not sure why Linux keeps returning this error. I don't know much about ELF headers and I would really appreciate it if someone could explain to me what I am doing wrong here.

 Risposta accettata

Walter Roberson
Walter Roberson il 12 Gen 2016

0 voti

The S function needs to be recompiled for Linux .

8 Commenti

Stacey
Stacey il 12 Gen 2016
I tried doing this and I still got an error message. I tried to compile it from a .cpp file (which I tried to convert to .c file so I could compile it in Linux).
Walter Roberson
Walter Roberson il 12 Gen 2016
I didn't think anyone still maintained a C++ to C translator.
gcc should be quite capable of compiling C++ code on Linux, provided that the code does not rely on MS Windows constructs.
Stacey
Stacey il 13 Gen 2016
Modificato: Stacey il 13 Gen 2016
How do I use gcc to compile?
The code only relies on a .cpp file and a couple of header files.
Walter Roberson
Walter Roberson il 13 Gen 2016
When you do mex -setup on Linux, gcc/g++ is the only option for C++
Stacey
Stacey il 13 Gen 2016
Got it. So I typed in "mex -setup C++" and then ran "mex MEXIrradition.cpp" I got this error message:
Building with 'g++'. Error using mex cc1plus: error: unrecognized command line option "-std=c++11"
I'm not sure what that means.
Stacey
Stacey il 13 Gen 2016
So I searched that error and found that it's probably because gcc is out of date. The machine I'm using has version 4.4.7. Not sure if there's any way around that.
Walter Roberson
Walter Roberson il 13 Gen 2016
You might be able to add one of -ansi, -std=c++98, or -std=c++03 between the "mex" and the filename. g++ usually pays attention to the last occurrence of an argument.
There is probably a make file that can be edited or perhaps an XML file used by mex -setup -- it would depend which MATLAB version you are using.
Stacey
Stacey il 13 Gen 2016
Adding those between "mex" and the filename didn't work. I'm not sure where I can find the XML file used by mex -setup and I'm not sure if I would have permission to modify the file since I'm not the admin. I just contacted the admin for the machine to see if we can update gcc. I think that's the easiest thing to do.

Accedi per commentare.

Più risposte (0)

Categorie

Community Treasure Hunt

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

Start Hunting!

Translated by