如何才能确定,如果我在32位或MATLAB的64位版本上运行?

我有一些预编译MEX-文件,这需要根据不同的路径对32位/ 64位MATLAB。

有帮助吗?

解决方案 2

背起上ScottieT812和DWJ建议,我发表我自己的解决方案,以赚取一些积分。

computer返回我跑的架构中的作用。这样:

switch computer
    case 'GLNX86'
        display('32-bit stuff')
    case 'GLNXA64'
        display('64-bit stuff')
    otherwise
        display('Not supported')
end

适用于我

其他提示

的32与64位的问题是一个真正的红色的鲱鱼。如果我理解正确的话,你要确定哪些编译MEX文件的设置都需要这样你就可以设置适当的路径。对于这一点,可以使用函数mexext

>> help mexext
 MEXEXT MEX filename extension for this platform, or all platforms. 
    EXT = MEXEXT returns the MEX-file name extension for the current
    platform. 

    ALLEXT = MEXEXT('all') returns a struct with fields 'arch' and 'ext' 
    describing MEX-file name extensions for all platforms.

    There is a script named mexext.bat on Windows and mexext.sh on UNIX
    that is intended to be used outside MATLAB in makefiles or scripts. Use
    that script instead of explicitly specifying the MEX-file extension in
    a makefile or script. The script is located in $MATLAB\bin.

    See also MEX, MEXDEBUG.

这是否真的有用吗?您正在使用哪个版本的MATLAB?

据我所知的64位平台与“64”不86.从MATLAB站点结束 http://www.mathworks.com/access/helpdesk/帮助/ techdoc / REF / computer.html 我不认为计算机永远不会返回GLNXA86但GLNXA64代替。

所以这个问题是特定于GNU Linux的32位或64位版本。

如果您正在测试的任何64位平台上,那么你可能需要测试的最后2个字符找到“64”,即像

if regexp(computer,'..$','match','64'),
   % setup 64bit options
else,
   % 32bit options
end
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top