如何使用 Boost 库构建 MEX 函数

How to you build a MEX function with Boost Libraries?

本文关键字:MEX 函数 构建 何使用 Boost      更新时间:2023-10-16

我正在尝试使用Boost库来编写多线程MEX函数。我已经安装了Boost库并使用Visual Studios对其进行了测试。我编写了以下 MEX 函数,并尝试在 MATLAB 控制台中构建它:

#include "mex.h"
#include <boost/filesystem.hpp>
#include <boost/lambda/bind.hpp>
#include <boost/thread/thread.hpp>
#include <boost/lockfree/spsc_queue.hpp>
#include <boost/atomic.hpp>
void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
{
}

这是输出

>> mex simpleBoostExample.cpp -IC:FolderOtherFolderMATLABFilesboostboost_1_67_0
Building with 'Microsoft Visual C++ 2017'.
Error using mex
LINK : fatal error LNK1104: cannot open file 'libboost_filesystem-vc141-mt-x64-1_67.lib'

现在我已经将 Boost 库文件添加到 MATLAB PATH 中,如下所示:

path(oldpath, 'C:FolderOtherFolderMATLABFilesboostboost_1_67_0')
setenv('PATH', [getenv('PATH') ';C:FolderOtherFolderMATLABFilesboostboost_1_67_0stagelib']);

所以我不确定我错过了什么。

使用 -L-l 与(可选)libfolder 中的动态对象库 libname 链接。

-LC:\Folder\OtherFolder\MATLAB\Files\boost\boost_1_67_0 -llibboost_filesystem-vc141-mt-x64-1_67.lib