C ++,Mac OS X,Xcode 8:编译Boost:将部署目标设置为OS X 10.11 [英] C++, Mac OS X, Xcode 8 : Compile Boost : Set deployment target to OS X 10.11

查看:263
本文介绍了C ++,Mac OS X,Xcode 8:编译Boost:将部署目标设置为OS X 10.11的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在Mac OS X 10.11.6上使用Boost CPP库.我从官方SourceForge存储库下载了1.62版本的Boost.按照以下文档提取并构建它: http://www.boost.org/doc/libs/1_62_0/more/getting_started/unix-variants.html

I am trying to use Boost CPP library on Mac OS X 10.11.6. I downloaded the 1.62 version of Boost from official SourceForge repository. Extracted it and built is as per the docs here: http://www.boost.org/doc/libs/1_62_0/more/getting_started/unix-variants.html

基本上,我进入目录并运行了"bootstrap.sh"和"b2"脚本.

Basically, I went to the directory and ran the "bootstrap.sh" and "b2" scripts.

然后我创建了一个简单的C ++程序:

Then I created a simple C++ program :

#include <iostream>
#include <string>

#include <boost/algorithm/string.hpp>
#include <boost/regex.hpp>

int main() {
  std::string str1(" hello world! ");
  boost::to_upper(str1);

  std::cout << str1 << std::endl;

  std::string s = " Boost Libraries ";
  boost::regex expr{"\\s"};
  std::string fmt{"_"};
  std::cout << boost::regex_replace(s, expr, fmt) << '\n';

  return 0;
}

并尝试使用以下CMake文件进行构建

And tried to build it with the following CMake file

cmake_minimum_required(VERSION 2.8.9)

set(CMAKE_CXX_FLAGS "-std=c++11 -stdlib=libc++")

project(app_project)

set(Boost_USE_STATIC_LIBS ON) 
set(Boost_USE_MULTITHREADED ON)  
set(Boost_USE_STATIC_RUNTIME ON) 

find_package(Boost 1.62.0 COMPONENTS regex) 

if(Boost_FOUND)
    include_directories(${Boost_INCLUDE_DIRS}) 
    add_executable(myapp main.cpp)
    target_link_libraries(myapp ${Boost_LIBRARIES})
endif()

制作程序时,我收到以下警告:

When I make the program I get following warnings:

ld: warning: object file (/Users/pritam/opt/boost_1_62_0/stage/lib/libboost_regex.a(instances.o)) was built for newer OSX version (10.12) than being linked (10.11)
ld: warning: object file (/Users/pritam/opt/boost_1_62_0/stage/lib/libboost_regex.a(regex.o)) was built for newer OSX version (10.12) than being linked (10.11)
ld: warning: object file (/Users/pritam/opt/boost_1_62_0/stage/lib/libboost_regex.a(regex_traits_defaults.o)) was built for newer OSX version (10.12) than being linked (10.11)
ld: warning: object file (/Users/pritam/opt/boost_1_62_0/stage/lib/libboost_regex.a(regex_raw_buffer.o)) was built for newer OSX version (10.12) than being linked (10.11)
ld: warning: object file (/Users/pritam/opt/boost_1_62_0/stage/lib/libboost_regex.a(cpp_regex_traits.o)) was built for newer OSX version (10.12) than being linked (10.11)
ld: warning: object file (/Users/pritam/opt/boost_1_62_0/stage/lib/libboost_regex.a(static_mutex.o)) was built for newer OSX version (10.12) than being linked (10.11)

我在此计算机上安装了XCode 8.似乎在构建Boost时,它将部署目标设置为OS X 10.12.

I have XCode 8 installed on this machine. It seems that while building Boost it sets the deployment target to OS X 10.12.

所以问题是:

在构建Boost时如何将部署目标设置为OS X 10.11?

How can I set the deployment target to OS X 10.11 while building Boost?

推荐答案

要定位的最低OSX版本低于要构建的当前OSX版本,则需要设置-mmacosx-version-min选项.因此,如果使用toolset=darwin,则需要构建为:

To target a minimum OSX version lower than your current OSX version you are building from you need to set the -mmacosx-version-min option. Hence, if you used toolset=darwin you would need to build as:

b2 macosx-version-min=10.11 ...

该工具集对OSX min版本具有特殊处理.或者,如果您使用的是toolset=clang,则您需要将其构建为:

As that toolset has special handling of the OSX min version. Or, if you used toolset=clang you would need to build as:

b2 cflags=-mmacosx-version-min=10.11 cxxflags=-mmacosx-version-min=10.11 mflags=-mmacosx-version-min=10.11 mmflags=-mmacosx-version-min=10.11 linkflags=-mmacosx-version-min=10.11 ...

这篇关于C ++,Mac OS X,Xcode 8:编译Boost:将部署目标设置为OS X 10.11的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆