开发者

Boost lib linker error Visual C++

开发者 https://www.devze.com 2022-12-12 20:24 出处:网络
I downloaded the source for Launchy and am trying to build it in Visual Studio 2005.The Launchy project is built using VC7 so I had to update the project files to VC8 and that process seemed to go wel

I downloaded the source for Launchy and am trying to build it in Visual Studio 2005. The Launchy project is built using VC7 so I had to update the project files to VC8 and that process seemed to go well. However, Launchy also uses the Boost 1.33.1 libs and what I have built are the Boost 1.41.0 libs (props to Boost for making the more recent libs much easier to build), so I also updated the project to point to my new Boost libs install. Now I get the following linker error:

fatal error LNK1104: cannot open file 'libboost_regex-vc80-mt-sgd-1_41.lib'

I had a look in the Boost lib directory and the closest match that I could find is...

libboost_regex-vc80-mt-gd-1_41.lib

Notice the missing 's'. I don't understand what the difference in libs is, and whether Visual Studio is looking for the wrong thing or my Boost build process failed to build the right libs. Can anybody point me in the right direction?

As an experiment, I made a copy of the regex lib that I have and renamed it to what the linker is looking for. That gives me a long list of linker errors about symbols already being defined in msvcrtd.lib, such as the following:

error LNK2005: "private: __thiscall type_info::type_info(class type_info const &)" (??0type_info@@AAE@A开发者_开发技巧BV0@@Z) already defined in libcmtd.lib(typinfo.obj)

I will try to build the Boost 1.33.1 libs and point my Launchy project file at that instead. But I'd still like to know what is wrong with my Boost 1.41.0 libs.

Edit: I found a reference in the Boost docs to what the 's' libs are:

Use this library when linking statically to the C++ standard library and compiler runtime support libraries.

So it looks like the 's' libs are the right ones. Now I just have to figure out how to build them.

Solution: I was able to build the missing boost libs with the following command-line.

bjam --build-type=complete msvc stage

I ran that after already running boostrap.bat in the dir where boost lives.


Difference is clearly described in Boost docs - "mt-sgd" means "debug, statically linked runtime libraries, multithreaded, with debug symbols". "mt-gd" is the same, but using dynamically linked runtime libraries (i.e. msvcrtd.lib instead of libcmtd.lib).

Either change project settings to use dynamic CRT linking (i.e. /MDd instead of /MTd), or build Boost using static linking - mixing those won't work properly.


What command did you use to build boost? try specifying build-type=complete. Normally it should build the s libs too.

0

精彩评论

暂无评论...
验证码 换一张
取 消