如何在xcode 4中使用boost :: test来测试一些ios c ++代码? [英] How can I use boost::test with xcode 4 for testing some ios c++ code?

查看:70
本文介绍了如何在xcode 4中使用boost :: test来测试一些ios c ++代码?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我希望它的运行方式与普通测试框架的运行方式类似-如果您从产品"->运行测试"菜单项进行测试,则输出应出现在左侧边栏窗口中.

I would like it to operate similarly to how the normal test framework works - if you the tests from the Product->Run tests menu item, the output should appear in the left sidebar window.

我找到了使用带有增强测试的xcode 3的指南,但无法弄清楚如何将这些指令翻译为xcode 4(如果可能的话).

I found a guide for using xcode 3 with boost test, but couldn't figure out how to translate those instructions for xcode 4 (if it is even possible).

最后,我正在构建一个iPhone应用程序.我可以使用#include <boost/test/included/unit_test.hpp>来加速运行,但是速度很慢.使用标准#include <boost/test/unit_test.hpp>会导致链接错误,因为该库是为错误的体系结构构建的.

Finally, I'm building an iPhone application. I could get boost running using the #include <boost/test/included/unit_test.hpp>, however it is pretty slow. Using the standard #include <boost/test/unit_test.hpp> results in link errors due to the library being built for the wrong architecture.

推荐答案

您应该使用.configure和make将boost库构建为静态库".a". 根据 :

You should build the boost library to a static library ".a" using .configure and make. According to this:

构建不需要特殊的构建选项或宏定义 静态库.使用Boost.Build系统,您可以构建 静态库,使用来自libs/test/build的以下命令 目录:

No special build options or macro definitions are required to build the static library. Using the Boost.Build system you can build the static library with the following command from libs/test/build directory:

bjam [-sTOOLS =] {-sBUILD = boost_unit_test_framework}

bjam [-sTOOLS=] {-sBUILD=boost_unit_test_framework}

此一个或多个库及其各自的标题需要添加到项目中. (需要两个内置版本,一个用于模拟器的i386和一个用于设备的ARM).

This library or libraries and their respective headers need to be added to the project. (Two built versions are needed, one i386 for the simulator and one ARM for devices).

  • 静态库是从Link Binary with Libraries中导入的 构建阶段.
  • 此外,您还需要告诉XCode使用哪些代码, 可以通过在构建设置-
  • "中设置竞争性构建设置来做到这一点
  • 库搜索路径.在此行的上方,将Header Search Path添加到boost头文件中.
  • The static library is imported from Link Binary with Libraries in Build Phases.
  • Also you need to tell XCode which of these to use, you can do this by setting contidional build settings in `Build settings-
  • Library search paths. Above this line is where you add the Header Search Path to the boost header files.

此后,您应该可以在您的C ++或Objective-C ++代码中包含标头(上面添加). (要制作Obj-C文件Obj-C ++文件,您需要将所有依赖的.m文件更改为.mm)

After this you should be able to include the headers (Added above) in C++ or objective-C++ code of yours. (To make Obj-C files Obj-C++ files you need to change all deppendent .m files to .mm)

如果在此之后出现一些问题,则在构建设置"中切换C ++的编译器或标准库可能会有所帮助.

If there is a some problems after this, switching Compiler or standard library for C++ in Build Settings might help.

这篇关于如何在xcode 4中使用boost :: test来测试一些ios c ++代码?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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