poster
2019-12-04, 02:55
我正在尝试使用mex从C ++创建MATLAB函数。对于C ++代码,我正在使用CLion。默认情况下,CLion中有一个CMakeLists.txt文件,该文件负责所有链接。当我直接在CLion中运行它时,它可以很好地工作,但是我不知道如何将其用于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) set(CMAKE_CXX_STANDARD 14) find_package(Matlab) matlab_add_mex( NAME mex_attempt SRC arrayProduct.cpp someFunctions.h someFunctions.cpp ) 当我在MATLAB中运行mex时,似乎无法理解包含内容。
>> 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) 这里有什么问题?非常感谢!
更多&回答... (https://stackoverflow.com/q/59163437)
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时,似乎无法理解包含内容。
>> 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) 这里有什么问题?非常感谢!
更多&回答... (https://stackoverflow.com/q/59163437)