为mex使用cmake 我试图用Max从C++中创建一个Matlab函数。对于C++代码,我使用的是CYON。根据CLion中的默认设置,有一个CMakeLists.txt文件,负责所有链接。当我直接在CLion中运行它时,它工作得很好,但是我不知道如何在mex中使用它:

为mex使用cmake 我试图用Max从C++中创建一个Matlab函数。对于C++代码,我使用的是CYON。根据CLion中的默认设置,有一个CMakeLists.txt文件,负责所有链接。当我直接在CLion中运行它时,它工作得很好,但是我不知道如何在mex中使用它:,c++,matlab,cmake,mex,C++,Matlab,Cmake,Mex,arrayProduct.cpp: #include "mex.h" #include "someFunctions.h" void mexFunction(...){ ... printRandomStuff(); // defined in someFunctions.h resp. someFunctions.cpp ... } CMakeLists.txt: cmake_minimum_required(VERSION 3.15) project(mex_attempt)

arrayProduct.cpp:

#include "mex.h"
#include "someFunctions.h"
void mexFunction(...){
  ...
  printRandomStuff(); // defined in someFunctions.h resp. someFunctions.cpp
  ...
}
CMakeLists.txt:

cmake_minimum_required(VERSION 3.15)
project(mex_attempt)

set(CMAKE_CXX_STANDARD 14)
find_package(Matlab)

matlab_add_mex(
        NAME mex_attempt
        SRC arrayProduct.cpp someFunctions.h someFunctions.cpp
)
当我在MATLAB中运行mex时,它似乎不理解include

>> mex /Users/username/CLionProjects/mex_attempt/arrayProduct.cpp
Error using mex
xcrun: error: SDK "macosx10.14.1" cannot be located
Undefined symbols for architecture x86_64:
  "printRandomStuff()", referenced from:
      _mexFunction in arrayProduct.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

这里有什么问题?非常感谢

根据第一条错误消息
xcrun:error:SDK“macosx10.14.1”无法定位
问题与包含标头无关。相反,您的常规设置有问题。你有没有试过用谷歌搜索这样的错误信息?请参阅或问题。非常感谢您的回答!如果我没有在arrayProduct.cpp中包含someFunctions.h,那么这个消息会显示大约四次,但最终它会起作用。。您认为这会导致问题吗?根据第一条错误消息
xcrun:error:SDK“macosx10.14.1”无法定位
问题与包含标头无关。相反,您的常规设置有问题。你有没有试过用谷歌搜索这样的错误信息?请参阅或问题。非常感谢您的回答!如果我没有在arrayProduct.cpp中包含someFunctions.h,那么这个消息会显示大约四次,但最终它会起作用。。你认为这会导致问题吗?