在matlab中使用函数库(gcc)和mex编译错误

在matlab中使用函数库(gcc)和mex编译错误,matlab,gcc,compiler-errors,mex,osx-yosemite,Matlab,Gcc,Compiler Errors,Mex,Osx Yosemite,我正在使用MacOSX(yosemite v10.10.1)并在其上运行Matlab2014a 我想在MATLAB上使用SPAM库(J.Mairal开发的稀疏建模软件),为此我必须安装XCode6.1(有gcc)。首先,我在命令窗口mex-setup中键入,结果如下所示: mex -setup MEX configured to use 'Xcode with Clang' for C language compilation. Warning: The MATLAB C and Fortra

我正在使用MacOSX(yosemite v10.10.1)并在其上运行Matlab2014a

我想在MATLAB上使用SPAM库(J.Mairal开发的稀疏建模软件),为此我必须安装XCode6.1(有gcc)。首先,我在命令窗口
mex-setup
中键入,结果如下所示:

mex -setup
MEX configured to use 'Xcode with Clang' for C language compilation.

Warning: The MATLAB C and Fortran API has changed to support MATLAB
     variables with more than 2^32-1 elements. In the near future
     you will be required to update your code to utilize the
     new API. You can find more information about this at:
     http://www.mathworks.com/help/matlab/matlab_external/upgrading-mex-files-to-use-64-bit-api.html.

To choose a different language, select one from the following:
 mex -setup C++ 
 mex -setup FORTRAN
因此,在那之后,我在垃圾邮件库中运行
compile.m
文件,突然发现一个错误:

add_flag =
 -mmacosx-version-min=10.6
Warning: Directory already exists. 
> In compile at 144 
compilation of: -I./linalg/ -I./decomp/ -I./prox/ -I./dictLearn/ dictLearn/mex/mexArchetypalAnalysis.cpp
Building with 'Xcode Clang++'.
clang: warning: argument unused during compilation: '-fopenmp'
Error using mex
ld: warning: directory not found for option '-L/usr/lib/gcc/x86_64-linux-gnu/4.8/'
ld: library not found for -lgomp
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Error in compile (line 439)
    mex(args{:});

我不知道该怎么办。请帮帮我

实际错误似乎发生在与预编译库链接时。这两个问题如下:

  • compile.m
    文件中包含的编译代码看起来像是要用gcc编译的(它试图包含由gcc安装的文件,甚至可能是特定于linux的文件,您确定它是OSX兼容的工具箱吗?),然而,这个错误强烈地表明您实际上是在使用clang来编译它——您要么需要更改编译器(容易),要么需要重写
    compile.m
    (不那么容易)

  • 尚未找到代码需要安装才能正确链接的库之一。在OSX上,我认为这个文件应该被称为
    libgomp.dylib
    (任何mac afficionados想要确认这一点吗?)。如果你的计算机上有它,那么它就不在clang正在查找的目录中。您可以通过从终端运行
    find/| grep libgomp.dylib
    来确认已安装库-如果存在库,您可以使用
    -I/DIRECTORY\u HOLDING\u library
    语法将其添加到
    compile.m
    中的编译器参数中


  • 完全有可能是1。也将补救2我从未尝试过使用垃圾邮件

    我也有同样的问题。你找到解决办法了吗?