Linking mex files to boost libraries
古いコメントを表示
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 件のコメント
José-Luis
2014 年 6 月 2 日
How about renaming the libraries to fit your needs? Or placing symbolic links that point to the right libraries?
José-Luis
2014 年 6 月 2 日
Note that when you compile the boost libraries yourself, you have some flexibility regarding the names you want to give them. You could also look at that alternative if the prospect of recompiling boost is more attractive than the one of setting a bunch of symbolic links.
Oliver Woodford
2014 年 6 月 2 日
José-Luis
2014 年 6 月 2 日
Also, beware that Matlab uses boost itself. This means that their version of boost is polluting the path. This makes for all kinds of fun when linking to another release.
I had that problem once and my solution was to give the entire path when linking. I was not using mex though.
Oliver Woodford
2014 年 6 月 3 日
回答 (0 件)
カテゴリ
ヘルプ センター および File Exchange で Call C/C++ from MATLAB についてさらに検索
製品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!