如何正确设置googletest在OS X除了XCode [英] How to properly setup googleTest on OS X aside from XCode
问题描述
如何设置gTest,以便我可以链接aganist库?我将在vim中编码,因此我只想安装库,这与 XCode设置不同。目标是能够通过设置 -lgtest
作为链接器标志链接项目和库,并且可选地,如果我没有编写自己的测试主例程,显式 -lgtest_main
标志。
How do I setup gTest, so that I can link aganist the library? I will code in vim, so I just want to install the libraries, unlike the XCode setup. Goal is to be able to link a project against the library by setting -lgtest
as linker flag and optionally, if I did not write my own test mainroutine, the explicit -lgtest_main
flag.
推荐答案
开始之前确保您已阅读并理解
来自Google的此附注!本教程使用gtest很容易,但可能会引入讨厌的错误。
Before you start make sure your have read and understood this note from Google! This tutorial makes using gtest easy, but may introduce nasty bugs.
$ wget http://googletest.googlecode.com/files/gtest-1.7.0.zip
或者通过 hand 。我想我不会管理这个小小的方法,所以如果你偶然发现它,并且链接已过时,请自由编辑它。
Or get it by hand. I guess I won't manitain this little How-to, so if you stumbled upon it and the links are outdated, feel free to edit it.
$ unzip gtest-1.7.0.zip
$ cd gtest-1.7.0
$ ./configure
$ make
3。 安装系统上的标题和库。
3. "Install" the headers and libs on your system.
$ sudo cp -a include/gtest /usr/include
$ sudo cp -a lib/.libs/* /usr/lib/
gTestframework使用。只要不要忘记通过将 -lgtest
设置为链接器标志来链接您的项目,如果没有编写自己的测试主例程,显式 -lgtest_main
标志。
gTestframework is now ready to use. Just don't forget to link your project against the library by setting -lgtest
as linker flag and optionally, if you did not write your own test mainroutine, the explicit -lgtest_main
flag.
从这里开始,您可能需要前往Googles 文档了解该框架如何工作。快乐编码!
From here on you might want to go to Googles documentation about the framework to learn how it works. Happy coding!
这篇关于如何正确设置googletest在OS X除了XCode的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!