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