c++ - 使用 cmake 进行墨西哥
问题描述
我正在尝试使用 mex 从 C++ 创建一个 MATLAB 函数。对于 C++ 代码,我使用的是 CLion。默认情况下,CLion 中有一个 CMakeLists.txt 文件,该文件负责所有链接。当我直接在 CLion 中运行它时,这很好用,但是我不知道如何将它用于 mex:
数组产品.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)
这里有什么问题?非常感谢!
解决方案
推荐阅读
- c# - 触发 HttpClient 的更简单方法(可能没有任务)?
- c# - c# - 以编程方式从 Outlook 电子邮件中删除附件
- java - 索引 for 循环的意外行为
- regex - 为什么正则表达式匹配不是我所期望的?
- reactjs - 如何修复,不等待响应,而是开始渲染
- java - 用特定输入修改最长回文子串条件。?
- python - 如何提取与满足条件的原始数组相同维度的数组?
- python - 使用wide_to_long时如何解决“id变量需要唯一标识每一行”的问题?
- wordpress - 为什么我的 svg 文件看起来比我的 png 文件差?
- javascript - 在javascript(react)Web应用程序中上传视频时的视频压缩