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) 5 6 /* 7 * LOCATION: see http://www.boost.org for most recent version. 8 * FILE auto_link.hpp 9 * VERSION see <boost/version.hpp> 10 * DESCRIPTION: Automatic library inclusion for Borland/Microsoft compilers. 11 */ 12 13 /************************************************************************* 14 15 USAGE: 16 ~~~~~~ 17 18 Before including this header you must define one or more of define the following macros: 19 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 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! 34 35 Algorithm: 36 ~~~~~~~~~~ 37 38 Libraries for Borland and Microsoft compilers are automatically 39 selected here, the name of the lib is selected according to the following 40 formula: 41 42 BOOST_LIB_PREFIX 43 + BOOST_LIB_NAME 44 + "_" 45 + BOOST_LIB_TOOLSET 46 + BOOST_LIB_THREAD_OPT 47 + BOOST_LIB_RT_OPT 48 "-" 49 + BOOST_LIB_VERSION 50 51 These are defined as: 52 53 BOOST_LIB_PREFIX: "lib" for static libraries otherwise "". 54 55 BOOST_LIB_NAME: The base name of the lib ( for example boost_regex). 56 57 BOOST_LIB_TOOLSET: The compiler toolset name (vc6, vc7, bcb5 etc). 58 59 BOOST_LIB_THREAD_OPT: "-mt" for multithread builds, otherwise nothing. 60 61 BOOST_LIB_RT_OPT: A suffix that indicates the runtime library used, 62 contains one or more of the following letters after 63 a hyphen: 64 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 p STLport build. 70 n STLport build without its IOStreams. 71 72 BOOST_LIB_VERSION: The Boost version, in the form x_y, for Boost version x.y. 73 74 75 ***************************************************************************/ 76 77 #ifdef __cplusplus 78 # ifndef BOOST_CONFIG_HPP 79 # include <boost/config.hpp> 80 # endif 81 #elif defined(_MSC_VER) && !defined(__MWERKS__) && !defined(__EDG_VERSION__) 82 // 83 // C language compatability (no, honestly) 84 // 85 # define BOOST_MSVC _MSC_VER 86 # define BOOST_STRINGIZE(X) BOOST_DO_STRINGIZE(X) 87 # define BOOST_DO_STRINGIZE(X) #X 88 #endif 89 // 90 // Only include what follows for known and supported compilers: 91 // 92 #if defined(BOOST_MSVC) \ 93 || defined(__BORLANDC__) \ 94 || (defined(__MWERKS__) && defined(_WIN32) && (__MWERKS__ >= 0x3000)) \ 95 || (defined(__ICL) && defined(_MSC_EXTENSIONS) && (_MSC_VER >= 1200)) 96 97 #ifndef BOOST_VERSION_HPP 98 # include <boost/version.hpp> 99 #endif 100 101 #ifndef BOOST_LIB_NAME 102 # error "Macro BOOST_LIB_NAME not set (internal error)" 103 #endif 104 105 // 106 // error check: 107 // 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" 112 #endif 113 // 114 // select toolset if not defined already: 115 // 116 #ifndef BOOST_LIB_TOOLSET 117 # if defined(BOOST_MSVC) && (BOOST_MSVC < 1200) 118 // Note: no compilers before 1200 are supported 119 # elif defined(BOOST_MSVC) && (BOOST_MSVC < 1300) 120 121 # ifdef UNDER_CE 122 // eVC4: 123 # define BOOST_LIB_TOOLSET "evc4" 124 # else 125 // vc6: 126 # define BOOST_LIB_TOOLSET "vc6" 127 # endif 128 129 # elif defined(BOOST_MSVC) && (BOOST_MSVC < 1310) 130 131 // vc7: 132 # define BOOST_LIB_TOOLSET "vc7" 133 134 # elif defined(BOOST_MSVC) && (BOOST_MSVC < 1400) 135 136 // vc71: 137 # define BOOST_LIB_TOOLSET "vc71" 138 139 # elif defined(BOOST_MSVC) && (BOOST_MSVC < 1500) 140 141 // vc80: 142 # define BOOST_LIB_TOOLSET "vc80" 143 144 # elif defined(BOOST_MSVC) && (BOOST_MSVC < 1600) 145 146 // vc90: 147 # define BOOST_LIB_TOOLSET "vc90" 148 149 # elif defined(BOOST_MSVC) && (BOOST_MSVC < 1700) 150 151 // vc10: 152 # define BOOST_LIB_TOOLSET "vc100" 153 154 # elif defined(BOOST_MSVC) && (BOOST_MSVC < 1800) 155 156 // vc11: 157 # define BOOST_LIB_TOOLSET "vc110" 158 159 # elif defined(BOOST_MSVC) && (BOOST_MSVC < 1900) 160 161 // vc12: 162 # define BOOST_LIB_TOOLSET "vc120" 163 164 # elif defined(BOOST_MSVC) && (BOOST_MSVC < 1910) 165 166 // vc14: 167 # define BOOST_LIB_TOOLSET "vc140" 168 169 # elif defined(BOOST_MSVC) 170 171 // vc14.1: 172 # define BOOST_LIB_TOOLSET "vc141" 173 174 # elif defined(__BORLANDC__) 175 176 // CBuilder 6: 177 # define BOOST_LIB_TOOLSET "bcb" 178 179 # elif defined(__ICL) 180 181 // Intel C++, no version number: 182 # define BOOST_LIB_TOOLSET "iw" 183 184 # elif defined(__MWERKS__) && (__MWERKS__ <= 0x31FF ) 185 186 // Metrowerks CodeWarrior 8.x 187 # define BOOST_LIB_TOOLSET "cw8" 188 189 # elif defined(__MWERKS__) && (__MWERKS__ <= 0x32FF ) 190 191 // Metrowerks CodeWarrior 9.x 192 # define BOOST_LIB_TOOLSET "cw9" 193 194 # endif 195 #endif // BOOST_LIB_TOOLSET 196 197 // 198 // select thread opt: 199 // 200 #if defined(_MT) || defined(__MT__) 201 # define BOOST_LIB_THREAD_OPT "-mt" 202 #else 203 # define BOOST_LIB_THREAD_OPT 204 #endif 205 206 #if defined(_MSC_VER) || defined(__MWERKS__) 207 208 # ifdef _DLL 209 210 # if (defined(__SGI_STL_PORT) || defined(_STLPORT_VERSION)) && (defined(_STLP_OWN_IOSTREAMS) || defined(__STL_OWN_IOSTREAMS)) 211 212 # if defined(_DEBUG) && (defined(__STL_DEBUG) || defined(_STLP_DEBUG))\ 213 && defined(BOOST_DEBUG_PYTHON) && defined(BOOST_LINKING_PYTHON) 214 # define BOOST_LIB_RT_OPT "-gydp" 215 # elif defined(_DEBUG) && (defined(__STL_DEBUG) || defined(_STLP_DEBUG)) 216 # define BOOST_LIB_RT_OPT "-gdp" 217 # elif defined(_DEBUG)\ 218 && defined(BOOST_DEBUG_PYTHON) && defined(BOOST_LINKING_PYTHON) 219 # define BOOST_LIB_RT_OPT "-gydp" 220 # pragma message("warning: STLport debug versions are built with /D_STLP_DEBUG=1") 221 # error "Build options aren't compatible with pre-built libraries" 222 # elif defined(_DEBUG) 223 # define BOOST_LIB_RT_OPT "-gdp" 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 # else 227 # define BOOST_LIB_RT_OPT "-p" 228 # endif 229 230 # elif defined(__SGI_STL_PORT) || defined(_STLPORT_VERSION) 231 232 # if defined(_DEBUG) && (defined(__STL_DEBUG) || defined(_STLP_DEBUG))\ 233 && defined(BOOST_DEBUG_PYTHON) && defined(BOOST_LINKING_PYTHON) 234 # define BOOST_LIB_RT_OPT "-gydpn" 235 # elif defined(_DEBUG) && (defined(__STL_DEBUG) || defined(_STLP_DEBUG)) 236 # define BOOST_LIB_RT_OPT "-gdpn" 237 # elif defined(_DEBUG)\ 238 && defined(BOOST_DEBUG_PYTHON) && defined(BOOST_LINKING_PYTHON) 239 # define BOOST_LIB_RT_OPT "-gydpn" 240 # pragma message("warning: STLport debug versions are built with /D_STLP_DEBUG=1") 241 # error "Build options aren't compatible with pre-built libraries" 242 # elif defined(_DEBUG) 243 # define BOOST_LIB_RT_OPT "-gdpn" 244 # pragma message("warning: STLport debug versions are built with /D_STLP_DEBUG=1") 245 # error "Build options aren't compatible with pre-built libraries" 246 # else 247 # define BOOST_LIB_RT_OPT "-pn" 248 # endif 249 250 # else 251 252 # if defined(_DEBUG) && defined(BOOST_DEBUG_PYTHON) && defined(BOOST_LINKING_PYTHON) 253 # define BOOST_LIB_RT_OPT "-gyd" 254 # elif defined(_DEBUG) 255 # define BOOST_LIB_RT_OPT "-gd" 256 # else 257 # define BOOST_LIB_RT_OPT 258 # endif 259 260 # endif 261 262 # else 263 264 # if (defined(__SGI_STL_PORT) || defined(_STLPORT_VERSION)) && (defined(_STLP_OWN_IOSTREAMS) || defined(__STL_OWN_IOSTREAMS)) 265 266 # if defined(_DEBUG) && (defined(__STL_DEBUG) || defined(_STLP_DEBUG))\ 267 && defined(BOOST_DEBUG_PYTHON) && defined(BOOST_LINKING_PYTHON) 268 # define BOOST_LIB_RT_OPT "-sgydp" 269 # elif defined(_DEBUG) && (defined(__STL_DEBUG) || defined(_STLP_DEBUG)) 270 # define BOOST_LIB_RT_OPT "-sgdp" 271 # elif defined(_DEBUG)\ 272 && defined(BOOST_DEBUG_PYTHON) && defined(BOOST_LINKING_PYTHON) 273 # define BOOST_LIB_RT_OPT "-sgydp" 274 # pragma message("warning: STLport debug versions are built with /D_STLP_DEBUG=1") 275 # error "Build options aren't compatible with pre-built libraries" 276 # elif defined(_DEBUG) 277 # define BOOST_LIB_RT_OPT "-sgdp" 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 # else 281 # define BOOST_LIB_RT_OPT "-sp" 282 # endif 283 284 # elif defined(__SGI_STL_PORT) || defined(_STLPORT_VERSION) 285 286 # if defined(_DEBUG) && (defined(__STL_DEBUG) || defined(_STLP_DEBUG))\ 287 && defined(BOOST_DEBUG_PYTHON) && defined(BOOST_LINKING_PYTHON) 288 # define BOOST_LIB_RT_OPT "-sgydpn" 289 # elif defined(_DEBUG) && (defined(__STL_DEBUG) || defined(_STLP_DEBUG)) 290 # define BOOST_LIB_RT_OPT "-sgdpn" 291 # elif defined(_DEBUG)\ 292 && defined(BOOST_DEBUG_PYTHON) && defined(BOOST_LINKING_PYTHON) 293 # define BOOST_LIB_RT_OPT "-sgydpn" 294 # pragma message("warning: STLport debug versions are built with /D_STLP_DEBUG=1") 295 # error "Build options aren't compatible with pre-built libraries" 296 # elif defined(_DEBUG) 297 # define BOOST_LIB_RT_OPT "-sgdpn" 298 # pragma message("warning: STLport debug versions are built with /D_STLP_DEBUG=1") 299 # error "Build options aren't compatible with pre-built libraries" 300 # else 301 # define BOOST_LIB_RT_OPT "-spn" 302 # endif 303 304 # else 305 306 # if defined(_DEBUG)\ 307 && defined(BOOST_DEBUG_PYTHON) && defined(BOOST_LINKING_PYTHON) 308 # define BOOST_LIB_RT_OPT "-sgyd" 309 # elif defined(_DEBUG) 310 # define BOOST_LIB_RT_OPT "-sgd" 311 # else 312 # define BOOST_LIB_RT_OPT "-s" 313 # endif 314 315 # endif 316 317 # endif 318 319 #elif defined(__BORLANDC__) 320 321 // 322 // figure out whether we want the debug builds or not: 323 // 324 #if __BORLANDC__ > 0x561 325 #pragma defineonoption BOOST_BORLAND_DEBUG -v 326 #endif 327 // 328 // sanity check: 329 // 330 #if defined(__STL_DEBUG) || defined(_STLP_DEBUG) 331 #error "Pre-built versions of the Boost libraries are not provided in STLport-debug form" 332 #endif 333 334 # ifdef _RTLDLL 335 336 # if defined(BOOST_BORLAND_DEBUG)\ 337 && defined(BOOST_DEBUG_PYTHON) && defined(BOOST_LINKING_PYTHON) 338 # define BOOST_LIB_RT_OPT "-yd" 339 # elif defined(BOOST_BORLAND_DEBUG) 340 # define BOOST_LIB_RT_OPT "-d" 341 # elif defined(BOOST_DEBUG_PYTHON) && defined(BOOST_LINKING_PYTHON) 342 # define BOOST_LIB_RT_OPT -y 343 # else 344 # define BOOST_LIB_RT_OPT 345 # endif 346 347 # else 348 349 # if defined(BOOST_BORLAND_DEBUG)\ 350 && defined(BOOST_DEBUG_PYTHON) && defined(BOOST_LINKING_PYTHON) 351 # define BOOST_LIB_RT_OPT "-syd" 352 # elif defined(BOOST_BORLAND_DEBUG) 353 # define BOOST_LIB_RT_OPT "-sd" 354 # elif defined(BOOST_DEBUG_PYTHON) && defined(BOOST_LINKING_PYTHON) 355 # define BOOST_LIB_RT_OPT "-sy" 356 # else 357 # define BOOST_LIB_RT_OPT "-s" 358 # endif 359 360 # endif 361 362 #endif 363 364 // 365 // select linkage opt: 366 // 367 #if (defined(_DLL) || defined(_RTLDLL)) && defined(BOOST_DYN_LINK) 368 # define BOOST_LIB_PREFIX 369 #elif defined(BOOST_DYN_LINK) 370 # error "Mixing a dll boost library with a static runtime is a really bad idea..." 371 #else 372 # define BOOST_LIB_PREFIX "lib" 373 #endif 374 375 // 376 // now include the lib: 377 // 378 #if defined(BOOST_LIB_NAME) \ 379 && defined(BOOST_LIB_PREFIX) \ 380 && defined(BOOST_LIB_TOOLSET) \ 381 && defined(BOOST_LIB_THREAD_OPT) \ 382 && defined(BOOST_LIB_RT_OPT) \ 383 && defined(BOOST_LIB_VERSION) 384 385 #ifdef BOOST_AUTO_LINK_TAGGED 386 # pragma comment(lib, BOOST_LIB_PREFIX BOOST_STRINGIZE(BOOST_LIB_NAME) BOOST_LIB_THREAD_OPT BOOST_LIB_RT_OPT ".lib") 387 # ifdef BOOST_LIB_DIAGNOSTIC 388 # pragma message ("Linking to lib file: " BOOST_LIB_PREFIX BOOST_STRINGIZE(BOOST_LIB_NAME) BOOST_LIB_THREAD_OPT BOOST_LIB_RT_OPT ".lib") 389 # endif 390 #elif defined(BOOST_AUTO_LINK_NOMANGLE) 391 # pragma comment(lib, BOOST_STRINGIZE(BOOST_LIB_NAME) ".lib") 392 # ifdef BOOST_LIB_DIAGNOSTIC 393 # pragma message ("Linking to lib file: " BOOST_STRINGIZE(BOOST_LIB_NAME) ".lib") 394 # endif 395 #elif defined(BOOST_LIB_BUILDID) 396 # 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 "-" BOOST_STRINGIZE(BOOST_LIB_BUILDID) ".lib") 397 # ifdef BOOST_LIB_DIAGNOSTIC 398 # 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 "-" BOOST_STRINGIZE(BOOST_LIB_BUILDID) ".lib") 399 # endif 400 #else 401 # 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") 402 # ifdef BOOST_LIB_DIAGNOSTIC 403 # 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") 404 # endif 405 #endif 406 407 #else 408 # error "some required macros where not defined (internal logic error)." 409 #endif 410 411 412 #endif // _MSC_VER || __BORLANDC__ 413 414 // 415 // finally undef any macros we may have set: 416 // 417 #ifdef BOOST_LIB_PREFIX 418 # undef BOOST_LIB_PREFIX 419 #endif 420 #if defined(BOOST_LIB_NAME) 421 # undef BOOST_LIB_NAME 422 #endif 423 // Don't undef this one: it can be set by the user and should be the 424 // same for all libraries: 425 //#if defined(BOOST_LIB_TOOLSET) 426 //# undef BOOST_LIB_TOOLSET 427 //#endif 428 #if defined(BOOST_LIB_THREAD_OPT) 429 # undef BOOST_LIB_THREAD_OPT 430 #endif 431 #if defined(BOOST_LIB_RT_OPT) 432 # undef BOOST_LIB_RT_OPT 433 #endif 434 #if defined(BOOST_LIB_LINK_OPT) 435 # undef BOOST_LIB_LINK_OPT 436 #endif 437 #if defined(BOOST_LIB_DEBUG_OPT) 438 # undef BOOST_LIB_DEBUG_OPT 439 #endif 440 #if defined(BOOST_DYN_LINK) 441 # undef BOOST_DYN_LINK 442 #endif 443 444 445