In MATLAB, I have a MEX file ending with .mexa64. That is, it is for Linux 64-bit.
Now, I wish to call the function in my Mac MATLAB, which requires .mexmaci64. How may I do the conversion? Is it possible?
It is impossible to do the conversion without recompilation.
Simply recompile the source code, e.g.,
mex sourceCode.c
It will automatically give you sourceCode.mexmaci64, if you are on OS X.
Related
I'm not sure where I'm supposed to ask this, so excuse me if stack overflow isn't the best place.
My question is if there are any differences between a .o file generated on Linux using gcc and a .o file on Mac OS X. If so, what are the differences exactly and why couldn't I use one from Linux on Mac or vice-versa?
They are completely different. OS X uses the Mach-O object file format. Linux uses the ELF object file format. They perform the same general purpose but in completely different ways.
A file ending in .o is an object file. The compiler creates an object file for each source file, before linking them together, into the final executable. Mac OS is based on a BSD code base, while Linux is an independent development of a unix-like system. This means that these systems are similar, but not binary compatible. To get it working compile the code on the OS that you will be using.
Read more on binary code compatibility:
https://en.wikipedia.org/wiki/Binary_code_compatibility
I am thinking about port some of my matlab (on windows) applications to linux, the application is integrated in matlab on Windows, it will call some external library routine (I mean DLL, not .mex files) thourgh matlab's calllib routine.
However due to the expensive license fee, I want to port this to Octave in Linux, I just want to make sure the Octave can handle the external binary libaries just as well as Matlab (My application seldom use matlab toolbox so the lack of certain toolboxes on Octave should not be a problem for me).
Last I checked, Octave did not implement the loadlibrary family of functions.
That doesn't mean you can't interface with this external library; you could always write a MEX/OCT wrapper function and call the library in your C/C++ code (I'm assuming this library has been ported to Linux in the first place!).
Generally, a DLL is incompatible to linux. Your application will not run on linux, neither with matlab nor with octave.
I am trying to compile a piece of software written in Fortran 77. I should point out that I don't know much at all about Fortran, and would really rather not start modifying the code for this software - particularly as I'm not sure what the licensing of the software is, and I don't know if I would be able to redistribute my modified version.
The code compiles fine on OS X and Windows using the g77 compiler that is (fairly easily) available for these systems. However, I cannot get it to work on my Ubuntu distribution, as I can't seem to get hold of g77 for Ubuntu anymore, and if I try and install an old version of it, it seems to muck up my entire GCC installation. I have tried compiling the code with both gfortran and g95, but it doesn't work with either as:
The code uses real variables as loop indices (yes, I know, bad idea). g95 supports this with the -freal-loops option, but gfortran doesn't.
The code uses real variables to index into arrays, which gfortran will support (with a warning), but g95 won't support.
Can anyone suggest a way to compile this code with those two 'dodgy' features using a modern and easily-available compiler such as g95 or gfortran?
Pass the argument -std=legacy to gfortran. Features removed in F95, like real loop and array indices, should compile (perhaps with a warning) in legacy mode.
I am looking to compile a .m file (program) from MATLAB to Linux. I have done it on Windows operating system using
mcc -mv FILENAME.m
I see on the MATLAB website that I can use GNU g++.
Does this work in a similar way to the MATLAB compiler by just writing one line of code in MATLAB or do I have to run it in the Linux terminal?
Also, does this compiler tend to have issues regarding getting the desired output?
What you want to do, is called crosscompiling. Here you want from a Windows computer cross compile a Matlab program to a native Linux executable. As of 2009, this was not possible and most likely isn't now either.
Perhaps you might try using Octave for Linux.
Download GNU Octave
This question already has answers here:
Closed 10 years ago.
Possible Duplicate:
Is a Linux executable “compatible” with OS X?
I have some c++ code compiled using GLUT and OpenGL on os x.
It all works fine. I have it as a.out
Is there a way to send this to someone using os x? Will there be some weird dependencies?
Can I send it to someone using linux?
I doubt I can do either which is why I'm asking on here. I looked around on google but couldn't find anything useful, I'm probably not searching for the right stuff
thanks
OS X and Linux have completely different binary formats (Mach-O/Universal Binary and ELF respectively), so no, a program compiled on OS X won't run on Linux unless you cross-compiled it.
If you compiled your code using static linking, then another OS X user will be able to use it just fine. However, bearing in mind that I know very little about GLUT or OpenGL, I'd bet good money that those are dynamic libraries, and thus whoever you send it to will need to have the same libraries installed in the same place in order to be able to use your compiled code.
otool -L will display the linkage dependencies of your executable, FYI.
It should work to send it to someone using the same version of OS X and the same computer chip as you. It may even be possible on OS X to cross-compile to a universal binary that works on Intel and PowerPC chips, but you'll still be limited to OS X.
To get a working executable for Linux, you'll need to compile it on Linux (or use a cross-compiler, but that could be more difficult than it's worth, especially if you have to do it repeatedly).
Or, as has been said already, you could just distribute the source code and let people compile it themselves. This may be the best approach, because C++ has no common binary format, so if different people use different compilers that have different forms of name-mangling, they'll all still get a program that works (if they compiled OpenGL or GLUT with one C++ compiler and then you compiled your program with another, they might not work together (I think)).
What about just sharing the source?
Are you afraid somebody's going to steal your precious work?