Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Build 32 and 64 bit libraries for boost at sametime?

Tags:

c++

boost

bjam

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

like image 240
PopcornKing Avatar asked Feb 01 '12 20:02

PopcornKing


3 Answers

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.

like image 191
GrafikRobot Avatar answered Oct 18 '22 09:10

GrafikRobot


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.

like image 44
Flexo Avatar answered Oct 18 '22 10:10

Flexo


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.

like image 6
StarShine Avatar answered Oct 18 '22 11:10

StarShine