在MATLAB r2013错误编译metismex [英] Error compiling metismex in matlab r2013

查看:796
本文介绍了在MATLAB r2013错误编译metismex的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经下载并成功地编译梅蒂斯5.0.2 在Win7的X64 PC
并试图编译 metismex
我编译梅蒂斯与Visual Studio 11(2012),并使用相同的编译器从MATLAB中。
很多实验一吨的错误(主要是库中所欠的路径问题从)之后,我已经达到了一个点,我不知道如何着手,因为我的C和C ++知识是pretty基础。
所以,这里的错误:

I have downloaded and succesfully compiled metis 5.0.2 in a win7 x64 pc and trying to compile metismex. I compiled metis with Visual Studio 11 (2012) and using the same compiler from within matlab. After a lot of experimentation with a ton of errors (mainly owed to paths issues from within the libraries) I have reached a point where I dont know how to proceed, since my knowledge on c and c++ is pretty basic. So, here's the error :

../GKlib/mat_libs/.\stddef.h(16) : error C2054: expected '(' to follow '_SIZE_TYPE__' 
../GKlib/mat_libs/.\stddef.h(19) : error C2085: '_WCHAR_TYPE__' : not in formal parameter list 

我发现了关于内联函数等,但由于错误是库中与不知道到底是我应该做的,我在这里。因此,错误code是这里出产的:

I found out about the inline functions etc, but since the error is within a library and dont exactly know what I should be doing, here I am. So, the error code is produced here :

 typedef __SIZE_TYPE__ size_t; 
#ifndef __cplusplus
typedef __WCHAR_TYPE__ wchar_t; 
#endif

这是我应该做的不搞乱它有什么建议?
(如果我注释掉WCHAR类型,我也有prtdiff_type相同的错误)
在此先感谢

any suggestions on what I should do without messing it up? (in case I comment out wchar type, I also have the same error on prtdiff_type) Thanks in advance

P.S:如果需要的话,这里是整个sttdef.h

P.S: In case it is needed, here's the whole sttdef.h

/* Copyright 2012 The MathWorks, Inc. */

#ifndef _STDDEF_H
#define _STDDEF_H

#ifdef __cplusplus
extern "C" {
#endif

#ifdef __cplusplus
#  define NULL (0)
#else
#  define NULL ((void *)0)
#endif

typedef __SIZE_TYPE__ size_t; 

#ifndef __cplusplus
typedef __WCHAR_TYPE__ wchar_t; 
#endif

typedef __PTRDIFF_TYPE__ ptrdiff_t;

#if (! defined(__cplusplus)) || (! defined(PST_GNU))
# define offsetof(type, field) ((size_t) &((type *)0)->field)
#else
# define offsetof(type, field)                            \
  (__offsetof__(reinterpret_cast<size_t>                  \
        (&reinterpret_cast<const volatile char &> \
         (static_cast<type *>(0)->field))))
#endif

#ifdef __cplusplus
} /* extern "C" */
#endif

#endif /* _STDDEF_H *

/

推荐答案

下面是什么,我做了一个步行通过。我跑R2014a与Win8.1 64 VS2013。

Here is a walk-through of what I did. I'm running R2014a with VS2013 on Win8.1 x64.

修改 C:\\梅蒂斯-5.1.0 \\包括\\ metis.h 并设置的#define IDXTYPEWIDTH 64 (用于基于x64架构)

Edit C:\metis-5.1.0\include\metis.h and set #define IDXTYPEWIDTH 64 (for x64 architecture)

接下来,我们使用生成CMake的Visual Studio项目:

Next we generate Visual Studio projects using CMake:

> cd C:\metis-5.1.0
> vsgen -G "Visual Studio 12 2013 Win64"


  • 在我们所建立的解决方案,我们需要首先解决的几件事情。有些头文件不必要重新定义了MSVC( metisbin.h metislib.h RINT 功能 gk_arch.h )。删除这些行:

  • Before we build the solution, we need to fix a few things first. Some header files are unnecessarily redefining rint function for MSVC (metisbin.h, metislib.h, and gk_arch.h). Remove such lines:

    #ifdef __MSC__ /* MSC does not have rint() function */
    #define rint(x) ((int)((x)+0.5))  
    
    /* MSC does not have INFINITY defined */
    #ifndef INFINITY
    #define INFINITY FLT_MAX
    #endif
    #endif
    


  • 另外在 GKlib \\ gk_externs.h 替换所有出现的__线程 __ declspec(线程)

    接下来打开解决方案文件 C:\\梅蒂斯-5.1.0 \\版本\\ WINDOWS \\ METIS.sln 在Visual Stduio,并建立 ALL_BUILD 目标(确保64,在释放模式中选择)。

    Next open the solution file C:\metis-5.1.0\build\windows\METIS.sln in Visual Stduio, and build ALL_BUILD target (make sure "x64" in "Release" mode is selected).

    我们的主要兴趣在梅蒂斯项目。其结果应存放在 C:\\梅蒂斯-5.1.0 \\版本\\ WINDOWS \\ libmetis \\发布\\ metis.lib (静态库)

    We are mainly interested in the metis project. Its result should be stored in C:\metis-5.1.0\build\windows\libmetis\Release\metis.lib (a static library).


    • metismex 并将其解压缩到previous位置中的文件夹( C:\\梅蒂斯-5.1.0 \\ metismex主

    同样,我们需要解决的几件事情:首先重命名 metismex.c metismex.cpp (C ++编译器比在Visual Studio C编译器好多了!)。接下来编辑这个文件,并替换:的#include&LT; strings.h&GT; 的#include&LT;文件string.h&GT; ,并立即添加以下code后:

    Again we need to fix a few things: first rename metismex.c to metismex.cpp (the C++ compiler is much better than the C compiler in Visual Studio!). Next edit this file and replace: #include <strings.h> with #include <string.h>, and add the following code immediately after it:

    #if defined(_WIN32) || defined(_WIN64)
      #define snprintf _snprintf
      #define vsnprintf _vsnprintf
      #define strcasecmp _stricmp
      #define strncasecmp _strnicmp
    #endif
    


  • 最后启动MATLAB,并运行以下命令来编译MEX文件:

  • Finally start MATLAB, and run the following command to compile the MEX-file:

    >> cd('C:\metis-5.1.0\metismex-master')
    >> mex -O -largeArrayDims -DWIN32 -DMSC -DUSE_GKREGEX -I../GKlib -I../include -I../libmetis metismex.cpp ../build/windows/libmetis/Release/metis.lib
    


  • 您现在应该有最后的 metismex.mexw64

    我应该说我一无所知库中,所以我不能保证它给所有上述修改之后正确的结果。我只是展示了如何得到它的编译。在code的考虑使用Linux / OSX写的,并且依赖于许多POSIX功能不适用于Windows操作系统。也是整个32与64位是有点乱......

    I should say that I know nothing about the library, so I cannot guarantee it gives correct results after all the above modifications. I'm just showing how to get it to compile. The code was written with Linux/OSX in mind, and relies on many POSIX features not intended for Windows. Also the whole 32 vs. 64 bit is a bit messy...

    这篇关于在MATLAB r2013错误编译metismex的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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