Linker error while compiling mexfunction with boost

1 view (last 30 days)
I'm trying to use boost in mexfunctions.
Given below is my code
main.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");
}
I compile it using the below command
mex main.cpp -LC:\Boost\1.55.0\VC\10.0\x64\stage\lib -IC:\Boost\1.55.0\VC\10.0\x64
Then i get this linking error
LINK : fatal error LNK1104: cannot open file 'libboost_thread-vc100-mt-1_55.lib'
C:\PROGRA~1\MATLAB\R2012A\BIN\MEX.PL: Error: Link of 'main.mexw64' failed.
Then I compiled again using,
mex main.cpp -LC:\Boost\1.55.0\VC\10.0\x64\stage\lib -IC:\Boost\1.55.0\VC\10.0\x64 -llibboost_thread-vc100-mt-s-1_55
&
mex main.cpp -LC:\Boost\1.55.0\VC\10.0\x64\stage\lib -IC:\Boost\1.55.0\VC\10.0\x64 -lboost_thread-vc100-mt-s-1_55
But still I get the same error. How can I solve this ?
EDIT :
I can use boost in a normal visual studio c++ project without any issue. The issue only comes when I put it in a mexfunction
  2 Comments
Kaustubha Govind
Kaustubha Govind on 30 Dec 2013
You might want to add the -v argument to your mex command to get a verbose log of the exact compiler/linker commands being run. You can compare these against your Visual Studio log to see what's different.
VINAYAK KARANDIKAR
VINAYAK KARANDIKAR on 28 Mar 2019
Hello,
i get a similar error:
LINK : fatal error LNK1104: cannot open file 'libboost_thread-vc100-mt-1_55.lib'
C:\PROGRA~1\MATLAB\R2013B\BIN\MEX.PL: Error: Link of 'uhdinterface.mexw64' failed.
What do i do?
Thanks a lot,
Vinayak Anant Karandikar

Sign in to comment.

Answers (0)

Categories

Find more on Write C Functions Callable from MATLAB (MEX Files) in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!