Linking mex files to boost libraries

조회 수: 3(최근 30일)
Oliver Woodford
Oliver Woodford 2014년 6월 2일
댓글: Oliver Woodford 2014년 6월 3일
Boost libraries have awkward names. They depend on all sorts of things: compiler version, library type, boost version, etc. E.g.: libboost_system-vc100-mt-1_51.lib. To help with this, boost functions tell the linker what libraries to include using a directive such as:
#pragma comment(lib, "libboost_system-vc100-mt-1_51.lib")
Now this is fine if the linker knows where to find the library. However, I'm building a mex file as follows:
mex -LMY_BOOST_LIB_DIR my_mex.cpp
(where MY_BOOST_LIB_DIR is correct for my system) and I get the error:
LINK : fatal error LNK1104: cannot open file 'libboost_system-vc100-mt-1_51.lib'
However, when I use:
mex -LMY_BOOST_LIB_DIR -llibboost_system-vc100-mt-1_51 my_mex.cpp
it works fine.
The issue is that I want to use MSVC's (as I'm on a Windows PC using that compiler) autolinking feature, but MATLAB's mex function doesn't appear to be passing the linker directory information through. Do you know a way round this?
  댓글 수: 5
Oliver Woodford
Oliver Woodford 2014년 6월 3일
Thanks. I will use the entire path when linking.

댓글을 달려면 로그인하십시오.



Find more on Introduction to Installation and Licensing 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!

Translated by