msvc linker wants to prepend "lib" to library names
Hi everyone, I'm working through an issue which no longer seems to be unique to me. I've found several instances of people having this same issue. As the subject suggests, I'm in a situation where the msvc linker is prepending "lib" to the referenced boost library (in this case, regex) for the project. However, the interesting thing is, it's not happening for me, only for others on my team. On my dev box, the project builds just fine. To the best of my knowledge, I have pushed up all required changes (I added the need for regex with some changes I put in place) to the Team Foundation Server. However, when my colleagues checkout the latest revision of this new solution, they are unable to build because of this. The simple question is, why is this happening? I'd like to understand what's going on rather than simply being told how to fix it. From the many hits I've looked through, I've tried a couple of things but they do not seem to fix the problem. I found a link that said the problem is because I needed to additionally link with comsupp.lib (I found an article on MS that instructs to link with comsuppw.lib or comsuppdw.lib instead) to which I tried, but that hasn't fixed the issue. I found another that suggested I define the macro BOOST_ALL_DYN_LINK in the source code, but this hasn't helped either. Our environment is that we've installed boost 1.47 via the installer from boost-pro. The solution has all appropriate directories mapped (include and library directories). Are there property settings in my project that I should look for? I've been able to glean that this problem has something to do with static vs. dynamic linking. Should I check in my linker options for something? I have done that extensively already, but I'm not a strong MS developer and could have easily missed something. Thanks, Andy
lib being added to the beginning of the library name represents linking
dynamically. In MS Visual Studio, you can change between Static and Dynamic
under Project / Properties / Configuration Properties / C/C++ / Code
Generation / Runtime Library. A setting of MD or MDd is Dynamic and MT or
MTd is Static, the appended 'd' representing debug capabilities. Try
swapping between the two types to see if it fixes the linking problem.
- - - - - - - - - - - -
*Nathan Currier*
On Thu, Feb 2, 2012 at 8:02 AM, Andy Falanga (afalanga) wrote: Hi everyone,**** ** ** I’m working through an issue which no longer seems to be unique to me.
I’ve found several instances of people having this same issue. As the
subject suggests, I’m in a situation where the msvc linker is prepending
“lib” to the referenced boost library (in this case, regex) for the
project. However, the interesting thing is, it’s not happening for me,
only for others on my team. On my dev box, the project builds just fine.
To the best of my knowledge, I have pushed up all required changes (I added
the need for regex with some changes I put in place) to the Team Foundation
Server. However, when my colleagues checkout the latest revision of this
new solution, they are unable to build because of this.**** ** ** The simple question is, why is this happening? I’d like to understand
what’s going on rather than simply being told how to fix it. From the many
hits I’ve looked through, I’ve tried a couple of things but they do not
seem to fix the problem. I found a link that said the problem is because I
needed to additionally link with comsupp.lib (I found an article on MS that
instructs to link with comsuppw.lib or comsuppdw.lib instead) to which I
tried, but that hasn’t fixed the issue. I found another that suggested I
define the macro BOOST_ALL_DYN_LINK in the source code, but this hasn’t
helped either.**** ** ** Our environment is that we’ve installed boost 1.47 via the installer from
boost-pro. The solution has all appropriate directories mapped (include
and library directories). Are there property settings in my project that I
should look for? I’ve been able to glean that this problem has something
to do with static vs. dynamic linking. Should I check in my linker options
for something? I have done that extensively already, but I’m not a strong
MS developer and could have easily missed something.**** ** ** ** ** Thanks,**** Andy**** _______________________________________________
Boost-users mailing list
Boost-users@lists.boost.org
http://lists.boost.org/mailman/listinfo.cgi/boost-users
On Thu, Feb 02, 2012 at 12:30:10PM -0700, Nathan Currier wrote:
lib being added to the beginning of the library name represents linking dynamically. In MS Visual Studio, you can change between Static and Dynamic under Project / Properties / Configuration Properties / C/C++ / Code Generation / Runtime Library. A setting of MD or MDd is Dynamic and MT or MTd is Static, the appended 'd' representing debug capabilities. Try swapping between the two types to see if it fixes the linking problem.
Please do not top-post (as per guidelines). Your post is dangerously incorrect. There are two very distinct concepts at work here: 1) having a static or import+dynamic Boost library, 2) having a Boost library built against the static or dynamic C++ runtime. A lib- prefix on Windows implies that the Boost library is a static library. The lack of the lib- prefix indicates that the library is an import library and has an associated DLL file. What you describe is what the -s- tag indicates, namely whether the C++ runtime library is statically or dynamically linked. The presence of -s- means that the static runtime is used. The lack of it means that the dynamic runtime is used. For the sake of completeness, -gd- means that the Boost library is built against the debug runtime (-g-) with debug code (-d), while their omission means that the release runtime is used and that debug code is not enabled. Please see the Getting Started guide's reference for more exact details: http://www.boost.org/doc/libs/1_48_0/more/getting_started/unix-variants.html... http://www.boost.org/doc/libs/1_48_0/more/getting_started/windows.html#libra... -- Lars Viklund | zao@acc.umu.se
-----Original Message----- From: boost-users-bounces@lists.boost.org [mailto:boost-users- bounces@lists.boost.org] On Behalf Of Lars Viklund Sent: Thursday, February 02, 2012 1:48 PM To: boost-users@lists.boost.org Subject: Re: [Boost-users] msvc linker wants to prepend "lib" to library names
lib being added to the beginning of the library name represents
dynamically. In MS Visual Studio, you can change between Static and Dynamic under Project / Properties / Configuration Properties / C/C++ / Code Generation / Runtime Library. A setting of MD or MDd is Dynamic and MT or MTd is Static, the appended 'd' representing debug capabilities. Try swapping between the two types to see if it fixes the linking
On Thu, Feb 02, 2012 at 12:30:10PM -0700, Nathan Currier wrote: linking problem.
Please do not top-post (as per guidelines).
Your post is dangerously incorrect. There are two very distinct concepts at work here: 1) having a static or import+dynamic Boost library, 2) having a Boost library built against the static or dynamic C++ runtime.
A lib- prefix on Windows implies that the Boost library is a static library. The lack of the lib- prefix indicates that the library is an import library and has an associated DLL file.
Thank you for clarifying this one. The first response didn't fit what I'd found on-line from many sources (to include boost.org).
What you describe is what the -s- tag indicates, namely whether the C++ runtime library is statically or dynamically linked. The presence of - s- means that the static runtime is used. The lack of it means that the dynamic runtime is used.
I finally found the auto_link.hpp file but I admit that I don't fully understand it. How does the system know to arrange for static over dynamic linking? This was quite confusing to me. For the moment, the problem is fixed with the inclusion of the macro BOOST_DYN_LINK in the additions I've made to the solution. For my own understanding, although we're making a DLL in this solution, would we want to use static linking or dynamic? I think I realize that the answer to this may possibly be, "It depends on your needs and that of your customer." However, this discussion has come up on the team since I've inadvertently "discovered" this issue. If you're making a DLL, what would be the "preferred" or "best practice" approach for linking with the Boost libraries? For the record, it was the Boost documentation, in concert with other postings online, that helped me to understand what was happening here. Thanks, Andy
On Fri, Feb 03, 2012 at 03:24:00PM +0000, Andy Falanga (afalanga) wrote:
Thank you for clarifying this one. The first response didn't fit what I'd found on-line from many sources (to include boost.org).
What you describe is what the -s- tag indicates, namely whether the C++ runtime library is statically or dynamically linked. The presence of - s- means that the static runtime is used. The lack of it means that the dynamic runtime is used.
I finally found the auto_link.hpp file but I admit that I don't fully understand it. How does the system know to arrange for static over dynamic linking? This was quite confusing to me. For the moment, the problem is fixed with the inclusion of the macro BOOST_DYN_LINK in the additions I've made to the solution.
For reference, the set of user-configurable defines are listed at: http://www.boost.org/doc/libs/1_48_0/libs/config/doc/html/index.html#boost_c... It also mentions that some libraries must be statically linked on some platforms, while some must be dynamically linked.
For my own understanding, although we're making a DLL in this solution, would we want to use static linking or dynamic? I think I realize that the answer to this may possibly be, "It depends on your needs and that of your customer." However, this discussion has come up on the team since I've inadvertently "discovered" this issue. If you're making a DLL, what would be the "preferred" or "best practice" approach for linking with the Boost libraries?
I've only been able to come up with two reasons why you would prefer to link Boost dynamically over linking it statically: 1. If you pass Boost types across a DLL interface boundary, you probably want to use a dynamic Boost library such that the same code runs in each module in your program that uses the types. If the Boost code is entirely contained inside of a module, this should not be necessary. For some libraries (I'm guessing Serialization), this could be very beneficial and would probably get rid of some of the more common multi-module issues people tend to encounter. 2. If you have multiple modules using the same Boost library, you might be able to reduce the code duplication between the modules by using dynamic Boost libraries, as the code then resides mostly in the shared library. The downsides of dynamic linking is that there's some state shared betwen the modules that use Boost in your project, and that no dead-code-elimination linker optimizations take place when dynamically linked, so your total deployment size may be larger. There is also the problem of having to deploy the DLLs separately in your installer, and if your program ends up in the %PATH%, the DLLs may interfere with other programs in the system by being accidentally loaded. Personally, I do not use the dynamic Boost libraries unless I have a concrete known benefit from using them. Static is always my default, and is the Boost auto-link default on Windows as far as I know. As for why your system might be preferring the dynamic libraries, there might be some environment variable or personal user setting in your project. Try looking for whether you have some personal customizations to your build settings or environment on your workstation. -- Lars Viklund | zao@acc.umu.se
participants (3)
-
Andy Falanga (afalanga)
-
Lars Viklund
-
Nathan Currier