在Mac上使用Boost进行链接器错误

在Mac上使用Boost进行链接器错误

本文介绍了在Mac上使用Boost进行链接器错误(OSX 10.10.02 | Xcode 6.1.1)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

最近,我开始在Windows上使用Boost处理一个项目.它需要跨平台,因此我也将其安装在Mac上.很遗憾;每当我将其添加到Xcode项目中时,都会给我带来大量的链接器错误和转换警告.

Recently I started working with Boost on Windows for a project. It needs to be cross-platform so I also installed it on Mac. Unfortunately; whenever I add it to the Xcode project it gives me a big slew of linker-errors and conversion-warnings.

链接错误之一的示例:

其中一个转换警告示例:

Example of one of the conversion-warnings:

我尝试了几种安装方法和配置方法,但仍然无法正常工作.

I tried several installation methods and configuration methods but it still won't work.

这些是我的步骤:

  1. 编译Boost或获取Boost的编译版本.
  2. 创建一个XCode项目.
  3. 输入主类中的示例代码.
  4. 将标头和库路径添加到Xcode项目文件中.
  5. 构建.
  1. Compile Boost or get a compiled version of Boost.
  2. Create an XCode project.
  3. Enter this sample code in the main class.
  4. Add the header and library paths to the Xcode project file.
  5. Build.

我尝试过的编译选项:

  • 使用官方指南从源进行编译.
  • 使用我在Stackoverflow上找到的一些脚本从源代码进行编译.
  • 安装冲泡软件包管理器并下载包含二进制文件的软件包.

我尝试过的配置选项:

  1. 将标头搜索路径设置为/usr/local/Cellar/boost/1.57.0/include或等效文件,以及将库搜索路径设置为/usr/local/Cellar/boost/1.57.0/lib或等效文件.
  2. 仅设置标题搜索路径,而不设置库路径.
  3. 选项1但递归(导致更多错误).
  1. Setting the header search path to /usr/local/Cellar/boost/1.57.0/include or equivalents andsetting the library search path to /usr/local/Cellar/boost/1.57.0/lib or the equivalents.
  2. Setting just the header search path but not the library path.
  3. Option 1 but recursive (causes more errors).

如果有人能指出我正确的方向,我将不胜感激.我认为这与Xcode有关,因为所有编译版本都给了我相同的错误.

I would appreciate it a lot if someone could point me in the right direction. I think it's something Xcode related since all of the compiled versions give me the same errors.

推荐答案

我找到了答案.将标头和库路径添加到项目搜索路径后,您需要转到构建阶段".在那里,您需要将所需的单个库添加到将库链接到二进制"小节中.您可以在lib文件夹(boost文件夹中)中找到必要的文件.

I found the answer. After the header- and library paths are added to the projects search paths you need to go to "Build Phases". There you need to add the individual libraries you need to the "link libraries to binary" subsection. You can find the necessary files in the lib folder (in the boost folder).

您可以选择具有.a扩展名或具有.mt.dylib扩展名的库文件.如果选择.a扩展名文件,则库将添加到程序的编译版本中.如果选择.mt.dylib文件,则这些库将不会添加到已编译的程序中.在这种情况下,您假设运行该程序的计算机上已经存在动态库文件.

You can choose for either the library files with .a extension or with the .mt.dylib extension. If you choose the .a extension files the library will be added to the compiled version of your program. If you choose the .mt.dylib files then the libraries will not be added to your compiled program. In this case you are assuming the dynamic library files are already present on the computer running the program.

这篇关于在Mac上使用Boost进行链接器错误(OSX 10.10.02 | Xcode 6.1.1)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-05 20:18