How can I use boost::test with xcode 4 for testing some ios c++ code?

六月ゝ 毕业季﹏ 提交于 2019-12-23 09:22:36

问题


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.

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).

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.


回答1:


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

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}

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).

  • 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.

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)

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



来源:https://stackoverflow.com/questions/8482524/how-can-i-use-boosttest-with-xcode-4-for-testing-some-ios-c-code

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!