1 // (C) Copyright John Maddock 2003.
2 // Use, modification and distribution are subject to the
3 // Boost Software License, Version 1.0. (See accompanying file
4 // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
7 * LOCATION: see http://www.boost.org for most recent version.
9 * VERSION see <boost/version.hpp>
10 * DESCRIPTION: Automatic library inclusion for Borland/Microsoft compilers.
13 /*************************************************************************
18 Before including this header you must define one or more of define the following macros:
20 BOOST_LIB_NAME: Required: A string containing the basename of the library,
21 for example boost_regex.
22 BOOST_LIB_TOOLSET: Optional: the base name of the toolset.
23 BOOST_DYN_LINK: Optional: when set link to dll rather than static library.
24 BOOST_LIB_DIAGNOSTIC: Optional: when set the header will print out the name
25 of the library selected (useful for debugging).
26 BOOST_AUTO_LINK_NOMANGLE: Specifies that we should link to BOOST_LIB_NAME.lib,
27 rather than a mangled-name version.
28 BOOST_AUTO_LINK_TAGGED: Specifies that we link to libraries built with the --layout=tagged option.
29 This is essentially the same as the default name-mangled version, but without
30 the compiler name and version, or the Boost version. Just the build options.
31 BOOST_AUTO_LINK_SYSTEM: Specifies that we link to libraries built with the --layout=system option.
32 This is essentially the same as the non-name-mangled version, but with
33 the prefix to differentiate static and dll builds
35 These macros will be undef'ed at the end of the header, further this header
36 has no include guards - so be sure to include it only once from your library!
41 Libraries for Borland and Microsoft compilers are automatically
42 selected here, the name of the lib is selected according to the following
49 + BOOST_LIB_THREAD_OPT
51 + BOOST_LIB_ARCH_AND_MODEL_OPT
58 BOOST_LIB_PREFIX: "lib" for static libraries otherwise "".
60 BOOST_LIB_NAME: The base name of the lib ( for example boost_regex).
62 BOOST_LIB_TOOLSET: The compiler toolset name (vc6, vc7, bcb5 etc).
64 BOOST_LIB_THREAD_OPT: "-mt" for multithread builds, otherwise nothing.
66 BOOST_LIB_RT_OPT: A suffix that indicates the runtime library used,
67 contains one or more of the following letters after
70 s static runtime (dynamic if not present).
71 g debug/diagnostic runtime (release if not present).
72 y Python debug/diagnostic runtime (release if not present).
73 d debug build (release if not present).
75 n STLport build without its IOStreams.
77 BOOST_LIB_ARCH_AND_MODEL_OPT: The architecture and address model
78 (-x32 or -x64 for x86/32 and x86/64 respectively)
80 BOOST_LIB_VERSION: The Boost version, in the form x_y, for Boost version x.y.
82 BOOST_LIB_SUFFIX: Static/import libraries extension (".lib", ".a") for the compiler.
84 ***************************************************************************/
87 # ifndef BOOST_CONFIG_HPP
88 # include <boost/config.hpp>
90 #elif defined(_MSC_VER) && !defined(__MWERKS__) && !defined(__EDG_VERSION__)
92 // C language compatability (no, honestly)
94 # define BOOST_MSVC _MSC_VER
95 # define BOOST_STRINGIZE(X) BOOST_DO_STRINGIZE(X)
96 # define BOOST_DO_STRINGIZE(X) #X
99 // Only include what follows for known and supported compilers:
101 #if defined(BOOST_MSVC) \
102 || defined(BOOST_EMBTC_WINDOWS) \
103 || defined(BOOST_BORLANDC) \
104 || (defined(__MWERKS__) && defined(_WIN32) && (__MWERKS__ >= 0x3000)) \
105 || (defined(__ICL) && defined(_MSC_EXTENSIONS) && (_MSC_VER >= 1200)) \
106 || (defined(BOOST_CLANG) && defined(BOOST_WINDOWS) && defined(_MSC_VER) && (__clang_major__ >= 4))
108 #ifndef BOOST_VERSION_HPP
109 # include <boost/version.hpp>
112 #ifndef BOOST_LIB_NAME
113 # error "Macro BOOST_LIB_NAME not set (internal error)"
119 #if defined(__MSVC_RUNTIME_CHECKS) && !defined(_DEBUG)
120 # pragma message("Using the /RTC option without specifying a debug runtime will lead to linker errors")
121 # pragma message("Hint: go to the code generation options and switch to one of the debugging runtimes")
122 # error "Incompatible build options"
125 // select toolset if not defined already:
127 #ifndef BOOST_LIB_TOOLSET
128 # if defined(BOOST_MSVC) && (BOOST_MSVC < 1200)
129 // Note: no compilers before 1200 are supported
130 # elif defined(BOOST_MSVC) && (BOOST_MSVC < 1300)
134 # define BOOST_LIB_TOOLSET "evc4"
137 # define BOOST_LIB_TOOLSET "vc6"
140 # elif defined(BOOST_MSVC) && (BOOST_MSVC < 1310)
143 # define BOOST_LIB_TOOLSET "vc7"
145 # elif defined(BOOST_MSVC) && (BOOST_MSVC < 1400)
148 # define BOOST_LIB_TOOLSET "vc71"
150 # elif defined(BOOST_MSVC) && (BOOST_MSVC < 1500)
153 # define BOOST_LIB_TOOLSET "vc80"
155 # elif defined(BOOST_MSVC) && (BOOST_MSVC < 1600)
158 # define BOOST_LIB_TOOLSET "vc90"
160 # elif defined(BOOST_MSVC) && (BOOST_MSVC < 1700)
163 # define BOOST_LIB_TOOLSET "vc100"
165 # elif defined(BOOST_MSVC) && (BOOST_MSVC < 1800)
168 # define BOOST_LIB_TOOLSET "vc110"
170 # elif defined(BOOST_MSVC) && (BOOST_MSVC < 1900)
173 # define BOOST_LIB_TOOLSET "vc120"
175 # elif defined(BOOST_MSVC) && (BOOST_MSVC < 1910)
178 # define BOOST_LIB_TOOLSET "vc140"
180 # elif defined(BOOST_MSVC) && (BOOST_MSVC < 1920)
183 # define BOOST_LIB_TOOLSET "vc141"
185 # elif defined(BOOST_MSVC) && (BOOST_MSVC < 1930)
188 # define BOOST_LIB_TOOLSET "vc142"
190 # elif defined(BOOST_MSVC)
193 # define BOOST_LIB_TOOLSET "vc143"
195 # elif defined(BOOST_EMBTC_WINDOWS)
197 // Embarcadero Clang based compilers:
198 # define BOOST_LIB_TOOLSET "embtc"
200 # elif defined(BOOST_BORLANDC)
203 # define BOOST_LIB_TOOLSET "bcb"
205 # elif defined(__ICL)
207 // Intel C++, no version number:
208 # define BOOST_LIB_TOOLSET "iw"
210 # elif defined(__MWERKS__) && (__MWERKS__ <= 0x31FF )
212 // Metrowerks CodeWarrior 8.x
213 # define BOOST_LIB_TOOLSET "cw8"
215 # elif defined(__MWERKS__) && (__MWERKS__ <= 0x32FF )
217 // Metrowerks CodeWarrior 9.x
218 # define BOOST_LIB_TOOLSET "cw9"
220 # elif defined(BOOST_CLANG) && defined(BOOST_WINDOWS) && defined(_MSC_VER) && (__clang_major__ >= 4)
223 # define BOOST_LIB_TOOLSET "clangw" BOOST_STRINGIZE(__clang_major__)
226 #endif // BOOST_LIB_TOOLSET
229 // select thread opt:
231 #if defined(_MT) || defined(__MT__)
232 # define BOOST_LIB_THREAD_OPT "-mt"
234 # define BOOST_LIB_THREAD_OPT
237 #if defined(_MSC_VER) || defined(__MWERKS__)
241 # if (defined(__SGI_STL_PORT) || defined(_STLPORT_VERSION)) && (defined(_STLP_OWN_IOSTREAMS) || defined(__STL_OWN_IOSTREAMS))
243 # if defined(_DEBUG) && (defined(__STL_DEBUG) || defined(_STLP_DEBUG))\
244 && defined(BOOST_DEBUG_PYTHON) && defined(BOOST_LINKING_PYTHON)
245 # define BOOST_LIB_RT_OPT "-gydp"
246 # elif defined(_DEBUG) && (defined(__STL_DEBUG) || defined(_STLP_DEBUG))
247 # define BOOST_LIB_RT_OPT "-gdp"
248 # elif defined(_DEBUG)\
249 && defined(BOOST_DEBUG_PYTHON) && defined(BOOST_LINKING_PYTHON)
250 # define BOOST_LIB_RT_OPT "-gydp"
251 # pragma message("warning: STLport debug versions are built with /D_STLP_DEBUG=1")
252 # error "Build options aren't compatible with pre-built libraries"
253 # elif defined(_DEBUG)
254 # define BOOST_LIB_RT_OPT "-gdp"
255 # pragma message("warning: STLport debug versions are built with /D_STLP_DEBUG=1")
256 # error "Build options aren't compatible with pre-built libraries"
258 # define BOOST_LIB_RT_OPT "-p"
261 # elif defined(__SGI_STL_PORT) || defined(_STLPORT_VERSION)
263 # if defined(_DEBUG) && (defined(__STL_DEBUG) || defined(_STLP_DEBUG))\
264 && defined(BOOST_DEBUG_PYTHON) && defined(BOOST_LINKING_PYTHON)
265 # define BOOST_LIB_RT_OPT "-gydpn"
266 # elif defined(_DEBUG) && (defined(__STL_DEBUG) || defined(_STLP_DEBUG))
267 # define BOOST_LIB_RT_OPT "-gdpn"
268 # elif defined(_DEBUG)\
269 && defined(BOOST_DEBUG_PYTHON) && defined(BOOST_LINKING_PYTHON)
270 # define BOOST_LIB_RT_OPT "-gydpn"
271 # pragma message("warning: STLport debug versions are built with /D_STLP_DEBUG=1")
272 # error "Build options aren't compatible with pre-built libraries"
273 # elif defined(_DEBUG)
274 # define BOOST_LIB_RT_OPT "-gdpn"
275 # pragma message("warning: STLport debug versions are built with /D_STLP_DEBUG=1")
276 # error "Build options aren't compatible with pre-built libraries"
278 # define BOOST_LIB_RT_OPT "-pn"
283 # if defined(_DEBUG) && defined(BOOST_DEBUG_PYTHON) && defined(BOOST_LINKING_PYTHON)
284 # define BOOST_LIB_RT_OPT "-gyd"
285 # elif defined(_DEBUG)
286 # define BOOST_LIB_RT_OPT "-gd"
288 # define BOOST_LIB_RT_OPT
295 # if (defined(__SGI_STL_PORT) || defined(_STLPORT_VERSION)) && (defined(_STLP_OWN_IOSTREAMS) || defined(__STL_OWN_IOSTREAMS))
297 # if defined(_DEBUG) && (defined(__STL_DEBUG) || defined(_STLP_DEBUG))\
298 && defined(BOOST_DEBUG_PYTHON) && defined(BOOST_LINKING_PYTHON)
299 # define BOOST_LIB_RT_OPT "-sgydp"
300 # elif defined(_DEBUG) && (defined(__STL_DEBUG) || defined(_STLP_DEBUG))
301 # define BOOST_LIB_RT_OPT "-sgdp"
302 # elif defined(_DEBUG)\
303 && defined(BOOST_DEBUG_PYTHON) && defined(BOOST_LINKING_PYTHON)
304 # define BOOST_LIB_RT_OPT "-sgydp"
305 # pragma message("warning: STLport debug versions are built with /D_STLP_DEBUG=1")
306 # error "Build options aren't compatible with pre-built libraries"
307 # elif defined(_DEBUG)
308 # define BOOST_LIB_RT_OPT "-sgdp"
309 # pragma message("warning: STLport debug versions are built with /D_STLP_DEBUG=1")
310 # error "Build options aren't compatible with pre-built libraries"
312 # define BOOST_LIB_RT_OPT "-sp"
315 # elif defined(__SGI_STL_PORT) || defined(_STLPORT_VERSION)
317 # if defined(_DEBUG) && (defined(__STL_DEBUG) || defined(_STLP_DEBUG))\
318 && defined(BOOST_DEBUG_PYTHON) && defined(BOOST_LINKING_PYTHON)
319 # define BOOST_LIB_RT_OPT "-sgydpn"
320 # elif defined(_DEBUG) && (defined(__STL_DEBUG) || defined(_STLP_DEBUG))
321 # define BOOST_LIB_RT_OPT "-sgdpn"
322 # elif defined(_DEBUG)\
323 && defined(BOOST_DEBUG_PYTHON) && defined(BOOST_LINKING_PYTHON)
324 # define BOOST_LIB_RT_OPT "-sgydpn"
325 # pragma message("warning: STLport debug versions are built with /D_STLP_DEBUG=1")
326 # error "Build options aren't compatible with pre-built libraries"
327 # elif defined(_DEBUG)
328 # define BOOST_LIB_RT_OPT "-sgdpn"
329 # pragma message("warning: STLport debug versions are built with /D_STLP_DEBUG=1")
330 # error "Build options aren't compatible with pre-built libraries"
332 # define BOOST_LIB_RT_OPT "-spn"
337 # if defined(_DEBUG)\
338 && defined(BOOST_DEBUG_PYTHON) && defined(BOOST_LINKING_PYTHON)
339 # define BOOST_LIB_RT_OPT "-sgyd"
340 # elif defined(_DEBUG)
341 # define BOOST_LIB_RT_OPT "-sgd"
343 # define BOOST_LIB_RT_OPT "-s"
350 #elif defined(BOOST_EMBTC_WINDOWS)
355 # define BOOST_LIB_RT_OPT "-d"
357 # define BOOST_LIB_RT_OPT
363 # define BOOST_LIB_RT_OPT "-sd"
365 # define BOOST_LIB_RT_OPT "-s"
370 #elif defined(BOOST_BORLANDC)
373 // figure out whether we want the debug builds or not:
375 #if BOOST_BORLANDC > 0x561
376 #pragma defineonoption BOOST_BORLAND_DEBUG -v
381 #if defined(__STL_DEBUG) || defined(_STLP_DEBUG)
382 #error "Pre-built versions of the Boost libraries are not provided in STLport-debug form"
387 # if defined(BOOST_BORLAND_DEBUG)\
388 && defined(BOOST_DEBUG_PYTHON) && defined(BOOST_LINKING_PYTHON)
389 # define BOOST_LIB_RT_OPT "-yd"
390 # elif defined(BOOST_BORLAND_DEBUG)
391 # define BOOST_LIB_RT_OPT "-d"
392 # elif defined(BOOST_DEBUG_PYTHON) && defined(BOOST_LINKING_PYTHON)
393 # define BOOST_LIB_RT_OPT "-y"
395 # define BOOST_LIB_RT_OPT
400 # if defined(BOOST_BORLAND_DEBUG)\
401 && defined(BOOST_DEBUG_PYTHON) && defined(BOOST_LINKING_PYTHON)
402 # define BOOST_LIB_RT_OPT "-syd"
403 # elif defined(BOOST_BORLAND_DEBUG)
404 # define BOOST_LIB_RT_OPT "-sd"
405 # elif defined(BOOST_DEBUG_PYTHON) && defined(BOOST_LINKING_PYTHON)
406 # define BOOST_LIB_RT_OPT "-sy"
408 # define BOOST_LIB_RT_OPT "-s"
416 // BOOST_LIB_ARCH_AND_MODEL_OPT
419 #if defined( _M_IX86 )
420 # define BOOST_LIB_ARCH_AND_MODEL_OPT "-x32"
421 #elif defined( _M_X64 )
422 # define BOOST_LIB_ARCH_AND_MODEL_OPT "-x64"
423 #elif defined( _M_ARM )
424 # define BOOST_LIB_ARCH_AND_MODEL_OPT "-a32"
425 #elif defined( _M_ARM64 )
426 # define BOOST_LIB_ARCH_AND_MODEL_OPT "-a64"
430 // select linkage opt:
432 #if (defined(_DLL) || defined(_RTLDLL)) && defined(BOOST_DYN_LINK)
433 # define BOOST_LIB_PREFIX
434 #elif defined(BOOST_DYN_LINK)
435 # error "Mixing a dll boost library with a static runtime is a really bad idea..."
437 # define BOOST_LIB_PREFIX "lib"
441 // now include the lib:
443 #if defined(BOOST_LIB_NAME) \
444 && defined(BOOST_LIB_PREFIX) \
445 && defined(BOOST_LIB_TOOLSET) \
446 && defined(BOOST_LIB_THREAD_OPT) \
447 && defined(BOOST_LIB_RT_OPT) \
448 && defined(BOOST_LIB_ARCH_AND_MODEL_OPT) \
449 && defined(BOOST_LIB_VERSION)
451 #if defined(BOOST_EMBTC_WIN64)
452 # define BOOST_LIB_SUFFIX ".a"
454 # define BOOST_LIB_SUFFIX ".lib"
457 #ifdef BOOST_AUTO_LINK_NOMANGLE
458 # pragma comment(lib, BOOST_STRINGIZE(BOOST_LIB_NAME) BOOST_LIB_SUFFIX)
459 # ifdef BOOST_LIB_DIAGNOSTIC
460 # pragma message ("Linking to lib file: " BOOST_STRINGIZE(BOOST_LIB_NAME) BOOST_LIB_SUFFIX)
462 #elif defined(BOOST_AUTO_LINK_TAGGED)
463 # pragma comment(lib, BOOST_LIB_PREFIX BOOST_STRINGIZE(BOOST_LIB_NAME) BOOST_LIB_THREAD_OPT BOOST_LIB_RT_OPT BOOST_LIB_ARCH_AND_MODEL_OPT BOOST_LIB_SUFFIX)
464 # ifdef BOOST_LIB_DIAGNOSTIC
465 # pragma message ("Linking to lib file: " BOOST_LIB_PREFIX BOOST_STRINGIZE(BOOST_LIB_NAME) BOOST_LIB_THREAD_OPT BOOST_LIB_RT_OPT BOOST_LIB_ARCH_AND_MODEL_OPT BOOST_LIB_SUFFIX)
467 #elif defined(BOOST_AUTO_LINK_SYSTEM)
468 # pragma comment(lib, BOOST_LIB_PREFIX BOOST_STRINGIZE(BOOST_LIB_NAME) BOOST_LIB_SUFFIX)
469 # ifdef BOOST_LIB_DIAGNOSTIC
470 # pragma message ("Linking to lib file: " BOOST_LIB_PREFIX BOOST_STRINGIZE(BOOST_LIB_NAME) BOOST_LIB_SUFFIX)
472 #elif defined(BOOST_LIB_BUILDID)
473 # pragma comment(lib, BOOST_LIB_PREFIX BOOST_STRINGIZE(BOOST_LIB_NAME) "-" BOOST_LIB_TOOLSET BOOST_LIB_THREAD_OPT BOOST_LIB_RT_OPT BOOST_LIB_ARCH_AND_MODEL_OPT "-" BOOST_LIB_VERSION "-" BOOST_STRINGIZE(BOOST_LIB_BUILDID) BOOST_LIB_SUFFIX)
474 # ifdef BOOST_LIB_DIAGNOSTIC
475 # pragma message ("Linking to lib file: " BOOST_LIB_PREFIX BOOST_STRINGIZE(BOOST_LIB_NAME) "-" BOOST_LIB_TOOLSET BOOST_LIB_THREAD_OPT BOOST_LIB_RT_OPT BOOST_LIB_ARCH_AND_MODEL_OPT "-" BOOST_LIB_VERSION "-" BOOST_STRINGIZE(BOOST_LIB_BUILDID) BOOST_LIB_SUFFIX)
478 # pragma comment(lib, BOOST_LIB_PREFIX BOOST_STRINGIZE(BOOST_LIB_NAME) "-" BOOST_LIB_TOOLSET BOOST_LIB_THREAD_OPT BOOST_LIB_RT_OPT BOOST_LIB_ARCH_AND_MODEL_OPT "-" BOOST_LIB_VERSION BOOST_LIB_SUFFIX)
479 # ifdef BOOST_LIB_DIAGNOSTIC
480 # pragma message ("Linking to lib file: " BOOST_LIB_PREFIX BOOST_STRINGIZE(BOOST_LIB_NAME) "-" BOOST_LIB_TOOLSET BOOST_LIB_THREAD_OPT BOOST_LIB_RT_OPT BOOST_LIB_ARCH_AND_MODEL_OPT "-" BOOST_LIB_VERSION BOOST_LIB_SUFFIX)
485 # error "some required macros where not defined (internal logic error)."
489 #endif // _MSC_VER || __BORLANDC__
492 // finally undef any macros we may have set:
494 #ifdef BOOST_LIB_PREFIX
495 # undef BOOST_LIB_PREFIX
497 #if defined(BOOST_LIB_NAME)
498 # undef BOOST_LIB_NAME
500 // Don't undef this one: it can be set by the user and should be the
501 // same for all libraries:
502 //#if defined(BOOST_LIB_TOOLSET)
503 //# undef BOOST_LIB_TOOLSET
505 #if defined(BOOST_LIB_THREAD_OPT)
506 # undef BOOST_LIB_THREAD_OPT
508 #if defined(BOOST_LIB_RT_OPT)
509 # undef BOOST_LIB_RT_OPT
511 #if defined(BOOST_LIB_ARCH_AND_MODEL_OPT)
512 # undef BOOST_LIB_ARCH_AND_MODEL_OPT
514 #if defined(BOOST_LIB_LINK_OPT)
515 # undef BOOST_LIB_LINK_OPT
517 #if defined(BOOST_LIB_DEBUG_OPT)
518 # undef BOOST_LIB_DEBUG_OPT
520 #if defined(BOOST_DYN_LINK)
521 # undef BOOST_DYN_LINK
523 #if defined(BOOST_LIB_SUFFIX)
524 # undef BOOST_LIB_SUFFIX