使用提升编译 mexfunction 时出现链接器错误
Linker error while compiling mexfunction with boost
我正在尝试在 mexfunctions 中使用 boost。
下面是我的代码
主.cpp
#include <mex.h>
#include <boost/thread.hpp>
#include <boost/date_time.hpp>
void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
{
mexPrintf("test boost");
}
我使用以下命令编译它
mex main.cpp -LC:Boost1.55.0VC10.0x64stagelib -IC:Boost1.55.0VC10.0x64
然后我得到这个链接错误
LINK : fatal error LNK1104: cannot open file 'libboost_thread-vc100-mt-1_55.lib'
C:PROGRA~1MATLABR2012ABINMEX.PL: Error: Link of 'main.mexw64' failed.
然后我再次编译使用,
mex main.cpp -LC:Boost1.55.0VC10.0x64stagelib -IC:Boost1.55.0VC10.0x64 -llibboost_thread-vc100-mt-s-1_55
但我仍然得到同样的错误。我该如何解决这个问题?
编辑:
我可以在普通的Visual Studio c ++项目中使用boost,没有任何问题。只有当我把它放在 mexfunction 中时,问题才会出现
我知道
这个问题现在已经很老了,但是我在 mex 上遇到了类似的问题,我不仅可以通过指定库目录搜索路径来解决它,还可以指定编译的库对象的名称。
为此,我使用了以下命令:
mex main.cpp -I<path/to/lib> -L<path/to/lib/objects> -l<object_name>
命令行选项 -l
用于告诉 mex 链接指定的对象库。然后,Mex将尝试查找添加到-l
中的任何内容,并为Windows和.LIBEXT for unix.
这里有一个带有真实路径的示例:
mex main.cpp -IC:boost_1_54_0 -LC:boost_1_54_0release -lthread
最后,在您的情况下,我建议您尝试:
mex main.cpp -IC:Boost1.55.0VC10.0x64 -LC:Boost1.55.0VC10.0x64stagelib -lthread
编辑:
我注意到定义BOOST_ALL_NO_LIB
也有帮助,因为当我删除此定义时,我再次收到错误。要定义符号名称,您可以使用命令行选项-D
只需添加-DBOOST_ALL_NO_LIB
相关文章:
- 静态数据成员的问题-修复链接错误会导致编译器错误
- Visual Studio mkl_link_tool.exe链接错误
- C++ 实现模板单例类时出现链接错误
- 使用类模板的方法链接错误
- MySQL C++连接器链接错误
- VS 2015 链接错误 无法构建依赖于 libcurl 的项目
- 运行 C++ 单元测试时LNK2005链接错误
- 对 CMake 中'cudaRegisterLinkedBinary'链接错误的未定义引用?
- 链接错误,包括我创建的相同头文件 - C++
- 在Embarcadero C++ Builder中生成的DLL未解决的外部链接错误
- 使用标头保护的多个定义链接错误
- 链接错误:未定义对 stdscr 和 wgetch 的引用
- 使用 Vivek 的 Vcam / 捕获源过滤器构建/链接错误
- 升压program_options中的链接错误
- 使用 g++ 预处理器进行替换会导致链接错误
- 在调试配置中编译工作正常,但发布会给出链接错误
- 相邻矩阵设置链接错误
- 包含常量变量并包含在多个文件中的标头的链接错误
- C++链接错误,我理解但无法解决
- 是什么导致macOS Mojave上的GoogleTest链接错误