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.
32 These macros will be undef'ed at the end of the header, further this header
33 has no include guards - so be sure to include it only once from your library!
38 Libraries for Borland and Microsoft compilers are automatically
39 selected here, the name of the lib is selected according to the following
46 + BOOST_LIB_THREAD_OPT
53 BOOST_LIB_PREFIX: "lib" for static libraries otherwise "".
55 BOOST_LIB_NAME: The base name of the lib ( for example boost_regex).
57 BOOST_LIB_TOOLSET: The compiler toolset name (vc6, vc7, bcb5 etc).
59 BOOST_LIB_THREAD_OPT: "-mt" for multithread builds, otherwise nothing.
61 BOOST_LIB_RT_OPT: A suffix that indicates the runtime library used,
62 contains one or more of the following letters after
65 s static runtime (dynamic if not present).
66 g debug/diagnostic runtime (release if not present).
67 y Python debug/diagnostic runtime (release if not present).
68 d debug build (release if not present).
69 g debug/diagnostic runtime (release if not present).
72 BOOST_LIB_VERSION: The Boost version, in the form x_y, for Boost version x.y.
75 ***************************************************************************/
78 # ifndef BOOST_CONFIG_HPP
79 # include <boost/config.hpp>
81 #elif defined(_MSC_VER) && !defined(__MWERKS__) && !defined(__EDG_VERSION__)
83 // C language compatability (no, honestly)
85 # define BOOST_MSVC _MSC_VER
86 # define BOOST_STRINGIZE(X) BOOST_DO_STRINGIZE(X)
87 # define BOOST_DO_STRINGIZE(X) #X
90 // Only include what follows for known and supported compilers:
92 #if defined(BOOST_MSVC) \
93 || defined(__BORLANDC__) \
94 || (defined(__MWERKS__) && defined(_WIN32) && (__MWERKS__ >= 0x3000)) \
95 || (defined(__ICL) && defined(_MSC_EXTENSIONS) && (_MSC_VER >= 1200))
97 #ifndef BOOST_VERSION_HPP
98 # include <boost/version.hpp>
101 #ifndef BOOST_LIB_NAME
102 # error "Macro BOOST_LIB_NAME not set (internal error)"
108 #if defined(__MSVC_RUNTIME_CHECKS) && !defined(_DEBUG)
109 # pragma message("Using the /RTC option without specifying a debug runtime will lead to linker errors")
110 # pragma message("Hint: go to the code generation options and switch to one of the debugging runtimes")
111 # error "Incompatible build options"
114 // select toolset if not defined already:
116 #ifndef BOOST_LIB_TOOLSET
117 // Note: no compilers before 1200 are supported
118 #if defined(BOOST_MSVC) && (BOOST_MSVC < 1300)
122 # define BOOST_LIB_TOOLSET "evc4"
125 # define BOOST_LIB_TOOLSET "vc6"
128 #elif defined(BOOST_MSVC) && (BOOST_MSVC == 1300)
131 # define BOOST_LIB_TOOLSET "vc7"
133 #elif defined(BOOST_MSVC) && (BOOST_MSVC == 1310)
136 # define BOOST_LIB_TOOLSET "vc71"
138 #elif defined(BOOST_MSVC) && (BOOST_MSVC == 1400)
141 # define BOOST_LIB_TOOLSET "vc80"
143 #elif defined(BOOST_MSVC) && (BOOST_MSVC == 1500)
146 # define BOOST_LIB_TOOLSET "vc90"
148 #elif defined(BOOST_MSVC) && (BOOST_MSVC == 1600)
151 # define BOOST_LIB_TOOLSET "vc100"
153 #elif defined(BOOST_MSVC) && (BOOST_MSVC >= 1700)
156 # define BOOST_LIB_TOOLSET "vc110"
158 #elif defined(__BORLANDC__)
161 # define BOOST_LIB_TOOLSET "bcb"
165 // Intel C++, no version number:
166 # define BOOST_LIB_TOOLSET "iw"
168 #elif defined(__MWERKS__) && (__MWERKS__ <= 0x31FF )
170 // Metrowerks CodeWarrior 8.x
171 # define BOOST_LIB_TOOLSET "cw8"
173 #elif defined(__MWERKS__) && (__MWERKS__ <= 0x32FF )
175 // Metrowerks CodeWarrior 9.x
176 # define BOOST_LIB_TOOLSET "cw9"
179 #endif // BOOST_LIB_TOOLSET
182 // select thread opt:
184 #if defined(_MT) || defined(__MT__)
185 # define BOOST_LIB_THREAD_OPT "-mt"
187 # define BOOST_LIB_THREAD_OPT
190 #if defined(_MSC_VER) || defined(__MWERKS__)
194 # if (defined(__SGI_STL_PORT) || defined(_STLPORT_VERSION)) && (defined(_STLP_OWN_IOSTREAMS) || defined(__STL_OWN_IOSTREAMS))
196 # if defined(_DEBUG) && (defined(__STL_DEBUG) || defined(_STLP_DEBUG))\
197 && defined(BOOST_DEBUG_PYTHON) && defined(BOOST_LINKING_PYTHON)
198 # define BOOST_LIB_RT_OPT "-gydp"
199 # elif defined(_DEBUG) && (defined(__STL_DEBUG) || defined(_STLP_DEBUG))
200 # define BOOST_LIB_RT_OPT "-gdp"
201 # elif defined(_DEBUG)\
202 && defined(BOOST_DEBUG_PYTHON) && defined(BOOST_LINKING_PYTHON)
203 # define BOOST_LIB_RT_OPT "-gydp"
204 # pragma message("warning: STLPort debug versions are built with /D_STLP_DEBUG=1")
205 # error "Build options aren't compatible with pre-built libraries"
206 # elif defined(_DEBUG)
207 # define BOOST_LIB_RT_OPT "-gdp"
208 # pragma message("warning: STLPort debug versions are built with /D_STLP_DEBUG=1")
209 # error "Build options aren't compatible with pre-built libraries"
211 # define BOOST_LIB_RT_OPT "-p"
214 # elif defined(__SGI_STL_PORT) || defined(_STLPORT_VERSION)
216 # if defined(_DEBUG) && (defined(__STL_DEBUG) || defined(_STLP_DEBUG))\
217 && defined(BOOST_DEBUG_PYTHON) && defined(BOOST_LINKING_PYTHON)
218 # define BOOST_LIB_RT_OPT "-gydpn"
219 # elif defined(_DEBUG) && (defined(__STL_DEBUG) || defined(_STLP_DEBUG))
220 # define BOOST_LIB_RT_OPT "-gdpn"
221 # elif defined(_DEBUG)\
222 && defined(BOOST_DEBUG_PYTHON) && defined(BOOST_LINKING_PYTHON)
223 # define BOOST_LIB_RT_OPT "-gydpn"
224 # pragma message("warning: STLPort debug versions are built with /D_STLP_DEBUG=1")
225 # error "Build options aren't compatible with pre-built libraries"
226 # elif defined(_DEBUG)
227 # define BOOST_LIB_RT_OPT "-gdpn"
228 # pragma message("warning: STLPort debug versions are built with /D_STLP_DEBUG=1")
229 # error "Build options aren't compatible with pre-built libraries"
231 # define BOOST_LIB_RT_OPT "-pn"
236 # if defined(_DEBUG) && defined(BOOST_DEBUG_PYTHON) && defined(BOOST_LINKING_PYTHON)
237 # define BOOST_LIB_RT_OPT "-gyd"
238 # elif defined(_DEBUG)
239 # define BOOST_LIB_RT_OPT "-gd"
241 # define BOOST_LIB_RT_OPT
248 # if (defined(__SGI_STL_PORT) || defined(_STLPORT_VERSION)) && (defined(_STLP_OWN_IOSTREAMS) || defined(__STL_OWN_IOSTREAMS))
250 # if defined(_DEBUG) && (defined(__STL_DEBUG) || defined(_STLP_DEBUG))\
251 && defined(BOOST_DEBUG_PYTHON) && defined(BOOST_LINKING_PYTHON)
252 # define BOOST_LIB_RT_OPT "-sgydp"
253 # elif defined(_DEBUG) && (defined(__STL_DEBUG) || defined(_STLP_DEBUG))
254 # define BOOST_LIB_RT_OPT "-sgdp"
255 # elif defined(_DEBUG)\
256 && defined(BOOST_DEBUG_PYTHON) && defined(BOOST_LINKING_PYTHON)
257 # define BOOST_LIB_RT_OPT "-sgydp"
258 # pragma message("warning: STLPort debug versions are built with /D_STLP_DEBUG=1")
259 # error "Build options aren't compatible with pre-built libraries"
260 # elif defined(_DEBUG)
261 # define BOOST_LIB_RT_OPT "-sgdp"
262 # pragma message("warning: STLPort debug versions are built with /D_STLP_DEBUG=1")
263 # error "Build options aren't compatible with pre-built libraries"
265 # define BOOST_LIB_RT_OPT "-sp"
268 # elif defined(__SGI_STL_PORT) || defined(_STLPORT_VERSION)
270 # if defined(_DEBUG) && (defined(__STL_DEBUG) || defined(_STLP_DEBUG))\
271 && defined(BOOST_DEBUG_PYTHON) && defined(BOOST_LINKING_PYTHON)
272 # define BOOST_LIB_RT_OPT "-sgydpn"
273 # elif defined(_DEBUG) && (defined(__STL_DEBUG) || defined(_STLP_DEBUG))
274 # define BOOST_LIB_RT_OPT "-sgdpn"
275 # elif defined(_DEBUG)\
276 && defined(BOOST_DEBUG_PYTHON) && defined(BOOST_LINKING_PYTHON)
277 # define BOOST_LIB_RT_OPT "-sgydpn"
278 # pragma message("warning: STLPort debug versions are built with /D_STLP_DEBUG=1")
279 # error "Build options aren't compatible with pre-built libraries"
280 # elif defined(_DEBUG)
281 # define BOOST_LIB_RT_OPT "-sgdpn"
282 # pragma message("warning: STLPort debug versions are built with /D_STLP_DEBUG=1")
283 # error "Build options aren't compatible with pre-built libraries"
285 # define BOOST_LIB_RT_OPT "-spn"
290 # if defined(_DEBUG)\
291 && defined(BOOST_DEBUG_PYTHON) && defined(BOOST_LINKING_PYTHON)
292 # define BOOST_LIB_RT_OPT "-sgyd"
293 # elif defined(_DEBUG)
294 # define BOOST_LIB_RT_OPT "-sgd"
296 # define BOOST_LIB_RT_OPT "-s"
303 #elif defined(__BORLANDC__)
306 // figure out whether we want the debug builds or not:
308 #if __BORLANDC__ > 0x561
309 #pragma defineonoption BOOST_BORLAND_DEBUG -v
314 #if defined(__STL_DEBUG) || defined(_STLP_DEBUG)
315 #error "Pre-built versions of the Boost libraries are not provided in STLPort-debug form"
320 # if defined(BOOST_BORLAND_DEBUG)\
321 && defined(BOOST_DEBUG_PYTHON) && defined(BOOST_LINKING_PYTHON)
322 # define BOOST_LIB_RT_OPT "-yd"
323 # elif defined(BOOST_BORLAND_DEBUG)
324 # define BOOST_LIB_RT_OPT "-d"
325 # elif defined(BOOST_DEBUG_PYTHON) && defined(BOOST_LINKING_PYTHON)
326 # define BOOST_LIB_RT_OPT -y
328 # define BOOST_LIB_RT_OPT
333 # if defined(BOOST_BORLAND_DEBUG)\
334 && defined(BOOST_DEBUG_PYTHON) && defined(BOOST_LINKING_PYTHON)
335 # define BOOST_LIB_RT_OPT "-syd"
336 # elif defined(BOOST_BORLAND_DEBUG)
337 # define BOOST_LIB_RT_OPT "-sd"
338 # elif defined(BOOST_DEBUG_PYTHON) && defined(BOOST_LINKING_PYTHON)
339 # define BOOST_LIB_RT_OPT "-sy"
341 # define BOOST_LIB_RT_OPT "-s"
349 // select linkage opt:
351 #if (defined(_DLL) || defined(_RTLDLL)) && defined(BOOST_DYN_LINK)
352 # define BOOST_LIB_PREFIX
353 #elif defined(BOOST_DYN_LINK)
354 # error "Mixing a dll boost library with a static runtime is a really bad idea..."
356 # define BOOST_LIB_PREFIX "lib"
360 // now include the lib:
362 #if defined(BOOST_LIB_NAME) \
363 && defined(BOOST_LIB_PREFIX) \
364 && defined(BOOST_LIB_TOOLSET) \
365 && defined(BOOST_LIB_THREAD_OPT) \
366 && defined(BOOST_LIB_RT_OPT) \
367 && defined(BOOST_LIB_VERSION)
369 #ifdef BOOST_AUTO_LINK_TAGGED
370 # pragma comment(lib, BOOST_LIB_PREFIX BOOST_STRINGIZE(BOOST_LIB_NAME) BOOST_LIB_THREAD_OPT BOOST_LIB_RT_OPT ".lib")
371 # ifdef BOOST_LIB_DIAGNOSTIC
372 # pragma message ("Linking to lib file: " BOOST_LIB_PREFIX BOOST_STRINGIZE(BOOST_LIB_NAME) BOOST_LIB_THREAD_OPT BOOST_LIB_RT_OPT ".lib")
374 #elif defined(BOOST_AUTO_LINK_NOMANGLE)
375 # pragma comment(lib, BOOST_STRINGIZE(BOOST_LIB_NAME) ".lib")
376 # ifdef BOOST_LIB_DIAGNOSTIC
377 # pragma message ("Linking to lib file: " BOOST_STRINGIZE(BOOST_LIB_NAME) ".lib")
380 # pragma comment(lib, BOOST_LIB_PREFIX BOOST_STRINGIZE(BOOST_LIB_NAME) "-" BOOST_LIB_TOOLSET BOOST_LIB_THREAD_OPT BOOST_LIB_RT_OPT "-" BOOST_LIB_VERSION ".lib")
381 # ifdef BOOST_LIB_DIAGNOSTIC
382 # 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_VERSION ".lib")
387 # error "some required macros where not defined (internal logic error)."
391 #endif // _MSC_VER || __BORLANDC__
394 // finally undef any macros we may have set:
396 #ifdef BOOST_LIB_PREFIX
397 # undef BOOST_LIB_PREFIX
399 #if defined(BOOST_LIB_NAME)
400 # undef BOOST_LIB_NAME
402 // Don't undef this one: it can be set by the user and should be the
403 // same for all libraries:
404 //#if defined(BOOST_LIB_TOOLSET)
405 //# undef BOOST_LIB_TOOLSET
407 #if defined(BOOST_LIB_THREAD_OPT)
408 # undef BOOST_LIB_THREAD_OPT
410 #if defined(BOOST_LIB_RT_OPT)
411 # undef BOOST_LIB_RT_OPT
413 #if defined(BOOST_LIB_LINK_OPT)
414 # undef BOOST_LIB_LINK_OPT
416 #if defined(BOOST_LIB_DEBUG_OPT)
417 # undef BOOST_LIB_DEBUG_OPT
419 #if defined(BOOST_DYN_LINK)
420 # undef BOOST_DYN_LINK