10

When I use Visual Studio 2012, with auto-linking, I don't need to add boost / POCO/ python libraries manually, they would be added automatically. And if I miss any library, I get message like that:

LINK : fatal error LNK1104: cannot open file 'libboost_system-vc110-mt-1_55.lib'

But how it knows which file I want to link? Maybe I want to link dynamically, using boost_system-vs110-mt-1_55.lib, or I want one with gd or sgd in name?

How it makes choice?

Problem is, that my program is looking for libboost_ ... (i.e. static) libraries, when search for system, threads and etc, but it wants boost_ (i.e. dynamic) for python, and I just don't understand why?

Arkady
  • 2,084
  • 3
  • 27
  • 48
  • if you by "auto-linking" are referring to using dlls, that doesn't free you from linking .libs as well. In order to use dlls at runtime, you need to know the content of those dlls at compile time, and that's where .lib files come into play. Regarding which version, runtime and mt/md (what kind of runtime module you're compiling, you can see it into VS' options for your project), you should first inspect your project to decide. – Marco A. Apr 02 '14 at 08:04
  • Yes, I understand how to make choice by myself, compiling that project using MinGW I have no problem. But Visual Studio takes choosing on itself, so I CAN'T choose, it makes it for me. And I wonder why it do such choice. My question really is - how Visual Studio makes it's choice and how I can manage it? – Arkady Apr 02 '14 at 08:13
  • You can control that from VS as well, take a look at the Linker->Input pane for the .libs included when linking and also in the Linker->General->Additional linking directories (IIRC) – Marco A. Apr 02 '14 at 08:16
  • Yes, I can do it, but that don't solves my problem. I need next list of boost libraries to load: system, thread, filesystem, date_time, python. Visual Studio, using auto-linking, wants system, thread, filesystem, date_time - as static, found it in $(BOOST_ROOT)/stage/lib and works well. But it also wants dynamic boost_python_..., that I don't have and I don't want to build. And if I add at Linker->Input menu libboost_python (static version), it still MISS (i.e. fatal error LNK 1104: cannot open file 'boost_python...') library, that IT choose for me automatically. – Arkady Apr 02 '14 at 08:29
  • How did you configure your project? CMake? In that case if VS wants a dynamic library that likely means something is using it into your code – Marco A. Apr 02 '14 at 08:45
  • No, to remove anything that can be inserted automatically by CMake, I manually created project in Studio, added there paths, sources, headers and try to build. It has nothing more :-( My code has no LoadLibrary-like functions call (so, without any explicit dynamic linking), but even if it has, how can my code order to use implicit dynamic linking instead if static linking? I thought that is not possible, am I wrong? – Arkady Apr 02 '14 at 08:57
  • Let's do it the easy way: remove the dependency you don't want and see what are the linking errors or the compilation errors (they're two different things) – Marco A. Apr 02 '14 at 08:59
  • I receive error: "LINK : fatal error LNK 1104: cannot open file 'boost_python-vc110-mt-gd-1_55.lib'". – Arkady Apr 02 '14 at 09:07
  • There must be that lib file specified somewhere (or specified by cmake at runtime). Delete it if you're sure you can do without – Marco A. Apr 02 '14 at 10:01
  • TotalCommander shows there is no "boost_python" in all files inside project folder. I just wonder where from it takes it. I would like to delete anything about boost_python, to load libboost_python, but it still wants it. – Arkady Apr 02 '14 at 10:20
  • @DavidKernin: You're totally misunderstanding "auto-linking" – MSalters Apr 02 '14 at 10:23

1 Answers1

7

Visual Studio allows #pragma directives in the source code to set linker options. For "auto-linking", Boost uses these #pragma's in combination with existing macro's.

In particular, it sounds like you are looking for the BOOST_ALL_DYN_LINK macro.

MSalters
  • 173,980
  • 10
  • 155
  • 350
  • 1
    As I understand from boost/system/config.hpp, if BOOST_ALL_DYN_LINK is not defined, I have to link all libraries as static, that works for all except python right now. I really want to link all libraries as static, so that flag is exactly what I need, and default macros is good enough. But even if I add it (BOOST_ALL_STATIC_LINK) manually, it doesn't works. Somehow my compiler thinks that boost.python can't be static. And it asks for dynamic python library even if flag BOOST_ALL_STATIC_LINK exists. And I don't know where to look to fix that. – Arkady Apr 02 '14 at 11:45
  • @Arkady: Try being specific, use `BOOST_PYTHON_STATIC_LIB` – MSalters Apr 02 '14 at 11:54