使用Visual Studio编译时的MEX选项 [英] MEX options when compiling with Visual Studio

查看:361
本文介绍了使用Visual Studio编译时的MEX选项的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

由于某些原因,我必须在Visual Studio环境下编译我的MEX文件.有很多教程,我的MEX文件运行正常.但是,有一些MEX选项,例如mex选项中的-largeArrayDims,我不知道在VS环境下该从哪里打开.谁能提供帮助?

For some reasons I have to compile my MEX files under the Visual studio environment. There are many tutorials and my MEX files are working fine. However, there are a few MEX options, say -largeArrayDims in mex options, which I do not know where to turn on under the VS environment. Can anyone offer help?

推荐答案

-largeArrayDims选项是对MATLAB中mex命令的切换,该命令仅指示不定义MX_COMPAT_32.因此,在Visual Studio中,您无需执行任何操作,因为默认情况下未定义.如果您想要相反的行为(-compatibleArrayDims),则在预处理器"部分中定义MX_COMPAT_32.来自tmwtypes.h:

The -largeArrayDims option is a switch to the mex command in MATLAB that simply indicates not to define MX_COMPAT_32. So, in Visual Studio, you don't have to do anything since this is not defined by default. If you want the opposite behavior (-compatibleArrayDims), then define MX_COMPAT_32 in the Preprocessor section. From tmwtypes.h:

tmwtypes.h

#ifdef MX_COMPAT_32
typedef int mwSize;
typedef int mwIndex;
typedef int mwSignedIndex;
#else
typedef size_t    mwSize;         /* unsigned pointer-width integer */
typedef size_t    mwIndex;        /* unsigned pointer-width integer */
typedef ptrdiff_t mwSignedIndex;  /* a signed pointer-width integer */
#endif

通常,使用属性表来设置用于构建MEX文件的所有必要设置(库依赖项,标头,MEX文件扩展名等)非常方便.在在GitHub .

In general, it is convenient to use a property sheet to set all the necessary settings for building a MEX file (library dependencies, headers, MEX-file extension, etc.). A single property sheet that works automatically for either 32-bit or 64-bit MATLAB can be found at GitHub.

在属性管理器中将属性表添加到MEX项目的每个构建配置中(右键单击诸如Debug | x64之类的配置,然后选择添加现有属性表".请参见

Add the property sheet to each build configuration for the MEX project in the Property Manager (right click on the configuration such as Debug | x64 and select "Add Existing Property Sheet". See this post for detailed instructions.

一些附加说明:

  1. 我更喜欢使用/EXPORT:mexFunction而不是.def文件.使用单个导出功能,这要简单得多.
  2. 属性表创建清单文件,但实际上不是必需的.
  3. 我包含libut.lib,它提供了一些不错的功能来检测MEX文件中的中断(CTRL-C).相关的声明(尽管这里离主题很远):
  1. I prefer to use /EXPORT:mexFunction instead of a .def file. With a single exported function, this is much simpler.
  2. The property sheet makes a manifest file, but it's really not necessary.
  3. I include libut.lib, which provides a few nice functions for detecting a break (CTRL-C) from within a MEX file. The relevant declarations (although this is way off topic here):

// prototype the break handling functions in libut (C library)
extern "C" bool utIsInterruptPending();
extern "C" void utSetInterruptPending(bool);

这篇关于使用Visual Studio编译时的MEX选项的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆