28

Will the option "--address-model=32,64" build both 32 and 64 libraries or do you have to do two separate builds?

2
  • 2
    For those of you compiling for i386 Mac OS and stumbled here, and it didn't work, then you were on the verge of committing suicide (like me), add this flag, too: architecture=x86
    – Mazyod
    Jun 19, 2013 at 0:41
  • 1
    I'm having a similar question. I can build boost 32 and 64 bit (the 32_64 suggestion in the answer below does NOT work on windows with version 1.57.0) and store them in different lib directories, but when referencing those libs, what is the best or suggested approach to organizing them? I want to be able to build 32 bit and 64 projects without having to swap between environment variables (e.g. when using cmake)
    – StarShine
    Apr 2, 2015 at 12:51

3 Answers 3

23

Doing:

b2 address-model=32,64

Or..

b2 address-model=32,64,32_64

Work and produces, depending on toolset and platform support, both 32 and 64 bit targets in the first case. And 32, 64, and 32+64 universal targets (most likely only on OSX using the darwin toolset. And by "works" I mean that I just tried it with my Boost library on OSX with the darwin toolset. Hence I suspect you have your syntax wrong, i.e. don't use "--name=values" as they are not options, but instead use "name=values" are the are requirement specifications.

5
  • 2
    Thanks for the syntax clarification! Maybe I'm being picky but shouldnt b2 be giving an error (warning at minimum) when the syntax is incorrect? I guess the moral of the story is be careful with b2!! Feb 3, 2012 at 5:29
  • It's not actually easy, from the POV of the b2 implementation, that the syntax is incorrect. It sees a correctly syntaxed option (anything that starts with "-", that it doesn't recognize, which is passed to the Jamfiles. Which all look at the option, in a modular way, and decide they don't handle. Hence there is no place where it can decide that the option is not valid. I.e. it just ends up being ignored. Which is an effect of the b2 CLI not being a closed syntax set. Feb 3, 2012 at 13:31
  • 20
    I think you will have a problem with this when it comes to getting the libraries out because unfortunately the 32 bit and 64 bit libraries have identical names. You need to run b2 twice. One time with, for example, "--stagedir=stage32 address-model=32" and one time with "--stagedir=stage64 address-model=64".
    – mheyman
    Mar 13, 2013 at 16:49
  • 1
    Where is the 32_64 option documented? I can't find it anywhere (and I don't believe it is actually possible to store both of them in the same lib/dll on windows)
    – StarShine
    Apr 2, 2015 at 12:52
  • 1
    @StarShine It's mentioned in the source, and in the darwin toolset comments. And like I said in my answer.. "most likely only on OSX using the darwin toolset." Jun 16, 2015 at 3:28
11

The documentation states (emphasis mine):

"Explicitly request either 32-bit or 64-bit code generation."

Note that it doesn't say "one or more of" or "at least one of", it says either ... or, which implies XOR in my reading of it and your experience matches that.

The comma in the list of allowed values is just to separate the two items in the set of allowed values.

2
  • The documentation also states: "The comma has special meaning only if the feature has a fixed set of values, so bjam include=static,shared is not treated specially." 32 and 64 seem fixed to me for address-model. Thanks for response. Feb 1, 2012 at 21:42
  • 1
    @PopcornKing - I think the "either .. or" comment on the specific flag supersedes any general remarks that otherwise apply
    – Flexo
    Feb 1, 2012 at 21:48
6

I ended up doing the following:

  • Store the 32 lib/dll builds in a separate folder called /lib32
  • Store the 64 lib/dll builds in a seaprate folder called /lib64

Both are preferably in a search path that boost is already checking, such as stage or the installation folder.

Then I added this block right after the search paths are assembled under the header ( the FindBoost.cmake file to edit is under share/cmake-3.1/Modules/ folder in your CMake installation folder )

Begin finding boost libraries


...

if(Boost_LIBRARY_DIR)

...

endif()

#generate 32 and 64 bit paths
if(WIN32)
    if(CMAKE_CL_64)
        #message("Finding BOOST on windows platform (64 bit)")
        SET(BOOST_libdir_suffix_gen "64")
    else()
        #message("Finding BOOST on windows platform (32 bit)")
        SET(BOOST_libdir_suffix_gen "32")
    endif()

    list(APPEND _boost_LIBRARY_SEARCH_DIRS_PLATFORMS "")
    foreach(SEARCH_DIR_NOPLATFORM ${_boost_LIBRARY_SEARCH_DIRS})
        list(APPEND _boost_LIBRARY_SEARCH_DIRS_PLATFORMS ${SEARCH_DIR_NOPLATFORM}${BOOST_libdir_suffix_gen})        
    endforeach()
    foreach(SEARCH_DIR_PLATFORM ${_boost_LIBRARY_SEARCH_DIRS_PLATFORMS})
         list (APPEND _boost_LIBRARY_SEARCH_DIRS ${SEARCH_DIR_PLATFORM})
    endforeach()
else()
    # no generation required (?)
endif()  

It will re-append all existing lib directories to the boost search path for libraries, suffixed with a 64 or 32 bit extension tag. This selects the correct target libs for linking, and you can safely regenerate any other dependent cmake library (like CGAL) for a 32 or 64 target build without resetting the boost dependency path.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.