Thread Subject: determination of the associated compiler and API lib locations

Subject: determination of the associated compiler and API lib locations

From: Sebastien Paris

Date: 12 Nov, 2009 08:25:03

Message: 1 of 3

Hello,


Who knows how to determine the compiler associated with the mex command. Want a function which returns a string such as :

comp = compiler;

where comp should be {lcc, msvc, gcc, ...} and whatever version of Matlab of course ...

Other point, I would like to know the location of librairies used by matlab such BLAS, LAPACK, etc ... A function returning something like

lib = APIllib;


where lib.blas = 'C:\Program Files\MATLAB\R2009a\extern\lib\win32\microsoft\libmwblas.lib'

for example.


Sebastien

Subject: determination of the associated compiler and API lib locations

From: Bruno Luong

Date: 12 Nov, 2009 08:35:19

Message: 2 of 3

"Sebastien Paris" <sebastien.paris.nospam@lsis.org> wrote in message <hdggou$9du$1@fred.mathworks.com>...
> Hello,
>
>
> Who knows how to determine the compiler associated with the mex command. Want a function which returns a string such as :
>
> comp = compiler;
>
> where comp should be {lcc, msvc, gcc, ...} and whatever version of Matlab of course ...
>
> Other point, I would like to know the location of librairies used by matlab such BLAS, LAPACK, etc ... A function returning something like
>
> lib = APIllib;
>
>
> where lib.blas = 'C:\Program Files\MATLAB\R2009a\extern\lib\win32\microsoft\libmwblas.lib'
>
> for example.
>
>
> Sebastien

Get the compiler, here is a tool from me.

>> getmexopts('COMPILER')

ans =

cl

function res = getmexopts(Tag)
% function res = getmexopts(Tag)
% Get the MCC or MEX configuration
% Author Bruno Luong <brunoluong@yahoo.com>
% Last update: 29-Jun-2009

if ispc()
    optpath=prefdir;
    optfile=[optpath filesep 'compopts.bat'];
    mexoptfile=[optpath filesep 'mexopts.bat'];
else
    optpath=matlabroot;
    optfile=[optpath '/bin/mbuildopts.sh'];
    mexoptfile=[optpath '/bin/mexopts.sh']; % not sure correct path
end

% Try to get MEX option first
fid=fopen(mexoptfile,'r');
if fid<=0
    % Next MCC options
    fid=fopen(optfile,'r');
end

if fid>0
    iscompilerline=@(S) (strcmp(S,['set ' Tag]));
    C=textscan(fid,'%s %s', 'delimiter', '=', 'whitespace', '');
    fclose(fid);
    cline=find(cellfun(iscompilerline,C{1}));
    if isempty(cline)
        error('getmexopt [Bruno]: cannot get Tag %s', Tag)
    end
    res=C{2}{cline};
    root=regexprep(matlabroot,'\\','\\\\');
    res = regexprep(res,'%MATLAB%',root);
else
    error('getmexopts [Bruno]: cannot open comopts.bat file')
end

% Bruno

Subject: determination of the associated compiler and API lib locations

From: Sebastien Paris

Date: 12 Nov, 2009 10:11:02

Message: 3 of 3

"Bruno Luong" <b.luong@fogale.findmycountry> wrote in message <hdghc7$g7n$1@fred.mathworks.com>...
> "Sebastien Paris" <sebastien.paris.nospam@lsis.org> wrote in message <hdggou$9du$1@fred.mathworks.com>...
> > Hello,
> >
> >
> > Who knows how to determine the compiler associated with the mex command. Want a function which returns a string such as :
> >
> > comp = compiler;
> >
> > where comp should be {lcc, msvc, gcc, ...} and whatever version of Matlab of course ...
> >
> > Other point, I would like to know the location of librairies used by matlab such BLAS, LAPACK, etc ... A function returning something like
> >
> > lib = APIllib;
> >
> >
> > where lib.blas = 'C:\Program Files\MATLAB\R2009a\extern\lib\win32\microsoft\libmwblas.lib'
> >
> > for example.
> >
> >
> > Sebastien
>
> Get the compiler, here is a tool from me.
>
> >> getmexopts('COMPILER')
>
> ans =
>
> cl
>
> function res = getmexopts(Tag)
> % function res = getmexopts(Tag)
> % Get the MCC or MEX configuration
> % Author Bruno Luong <brunoluong@yahoo.com>
> % Last update: 29-Jun-2009
>
> if ispc()
> optpath=prefdir;
> optfile=[optpath filesep 'compopts.bat'];
> mexoptfile=[optpath filesep 'mexopts.bat'];
> else
> optpath=matlabroot;
> optfile=[optpath '/bin/mbuildopts.sh'];
> mexoptfile=[optpath '/bin/mexopts.sh']; % not sure correct path
> end
>
> % Try to get MEX option first
> fid=fopen(mexoptfile,'r');
> if fid<=0
> % Next MCC options
> fid=fopen(optfile,'r');
> end
>
> if fid>0
> iscompilerline=@(S) (strcmp(S,['set ' Tag]));
> C=textscan(fid,'%s %s', 'delimiter', '=', 'whitespace', '');
> fclose(fid);
> cline=find(cellfun(iscompilerline,C{1}));
> if isempty(cline)
> error('getmexopt [Bruno]: cannot get Tag %s', Tag)
> end
> res=C{2}{cline};
> root=regexprep(matlabroot,'\\','\\\\');
> res = regexprep(res,'%MATLAB%',root);
> else
> error('getmexopts [Bruno]: cannot open comopts.bat file')
> end
>
> % Bruno


Thanks Bruno,


Works fine :)

Tags for this Thread

Everyone's Tags:

sin

Add a New Tag:

Separated by commas
Ex.: root locus, bode

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Tag Activity for This Thread
Tag Applied By Date/Time
sin xuelong chen 19 Jan, 2010 06:26:13
rssFeed for this Thread
 

MATLAB Central Terms of Use

NOTICE: Any content you submit to MATLAB Central, including personal information, is not subject to the protections which may be afforded information collected under other sections of The MathWorks, Inc. Web site. You are entirely responsible for all content that you upload, post, e-mail, transmit or otherwise make available via MATLAB Central. The MathWorks does not control the content posted by visitors to MATLAB Central and, does not guarantee the accuracy, integrity, or quality of such content. Under no circumstances will The MathWorks be liable in any way for any content not authored by The MathWorks, or any loss or damage of any kind incurred as a result of the use of any content posted, e-mailed, transmitted or otherwise made available via MATLAB Central. Read the complete Terms prior to use.

Contact us at files@mathworks.com