How to properly setup googleTest on OS X aside from XCode

后端 未结 3 591
别那么骄傲
别那么骄傲 2020-12-05 16:14

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

3条回答
  •  挽巷
    挽巷 (楼主)
    2020-12-05 16:31

    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.

    1. Get the googletest framework

    $ wget https://github.com/google/googletest/archive/release-1.8.0.zip
    

    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.

    2. Unzip and build google test

    $ unzip gtest-1.8.0.zip
    $ cd gtest-1.8.0
    $ ./configure
    $ make
    

    3. "Install" the headers and libs on your system.

    $ sudo cp -a include/gtest /usr/include
    $ sudo cp -a lib/.libs/* /usr/lib/
    

    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.

    From here on you might want to go to Googles documentation about the framework to learn how it works. Happy coding!

提交回复
热议问题