C++ 同时构建 32 位和 64 位库以进行提升?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/9102495/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Build 32 and 64 bit libraries for boost at sametime?
提问by PopcornKing
Will the option "--address-model=32,64" build both 32 and 64 libraries or do you have to do two separate builds?
选项“--address-model=32,64”是否会同时构建 32 和 64 库,还是必须进行两个单独的构建?
采纳答案by GrafikRobot
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.
在第一种情况下,根据工具集和平台支持,工作和生产 32 位和 64 位目标。和 32、64 和 32+64 通用目标(很可能只在使用darwin
工具集的OSX 上。“有效”我的意思是我只是在使用darwin
工具集的OSX 上用我的 Boost 库尝试过它。因此我怀疑你有你的语法错误,即不要使用“--name=values”,因为它们不是选项,而是使用“name=values”是需求规范。
回答by Flexo
The documentation states (emphasis mine):
文档说明(强调我的):
"Explicitly request either32-bit or64-bit code generation."
“显式请求任一32位或64位的代码的生成。”
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.
允许值列表中的逗号只是将允许值集中的两个项目分开。
回答by StarShine
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
- 将 32 个 lib/dll 版本存储在名为 /lib32 的单独文件夹中
- 将 64 个 lib/dll 版本存储在名为 /lib64 的 seaprate 文件夹中
Both are preferably in a search path that boost is already checking, such as stageor the installationfolder.
两者最好都在 boost 已经检查的搜索路径中,例如stage或安装文件夹。
Then I added this block right after the search paths are assembled under the header ( the FindBoost.cmakefile to edit is under share/cmake-3.1/Modules/folder in your CMake installation folder )
然后我在搜索路径在标题下组装后立即添加了这个块(要编辑的FindBoost.cmake文件位于 CMake 安装文件夹中的share/cmake-3.1/Modules/文件夹下)
Begin finding boost libraries
...
if(Boost_LIBRARY_DIR)
...
endif()
开始寻找 boost 库
...
如果(Boost_LIBRARY_DIR)
...
万一()
#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.
它将所有现有的 lib 目录重新附加到库的 boost 搜索路径,后缀为 64 或 32 位扩展标签。这将为链接选择正确的目标库,并且您可以安全地为 32 或 64 目标构建重新生成任何其他依赖 cmake 库(如 CGAL),而无需重置 boost 依赖路径。