[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Distinguish MEX files for different architectures

From: ajimenezp
Subject: Distinguish MEX files for different architectures
Date: Tue, 28 Jun 2011 02:41:28 -0700 (PDT)


In MATLAB, MEX files compiled for different architectures get different
extensions (.mexglx for 32-bit Linux, .mexa64 for 64-bit Linux, etc). And if
you have two MEX files myfile.mexglx and myfile.mexa64 in the same
directory, you simply invoke myfile() and Matlab will call the appropriate
version. This is very convenient when running Matlab simulations in a
cluster of computers, since a-priori it is difficult to know in what
architecture your job will be running. All you need to do is login once in
each type of machine, compile your MEX files, and leave them all in the same
directory: the right version will be run, no-matter what the architecture is
of the machine to which your job is finally assigned.

Since Octave does not use different extensions for MEX files compiled in
different architectures, can anyone propose a solution for this problem?
i.e., how to distinguish and choose correctly the compiled version of a MEX
file depending on the architecture of the machine in which Octave is

So far the best solution I have found is changing the name of the MEX files
(instead of the extensions), i.e, having two MEX files myfile32.mex and
myfile64.mex, and then use the output of computer() to create a function
handle. Something like:

str = computer();
if ~isempty(strfind(str, 'x86_64')
    myfile = str2func('myfile64');
else if ~isempty(strfind(str, 'i386')
    myfile = str2func('myfile32');

This works but it is not very elegant, because it also requires me to modify
my Makefiles that compile the MEX files in order to find out the
architecture and give appropriate names. And I wouldn't like to have to do
this for all the MEX files in my project!

Can anyone propose a better alternative?
Thanks for your help.

View this message in context:
Sent from the Octave - General mailing list archive at

reply via email to

[Prev in Thread] Current Thread [Next in Thread]