Reg : Setting Up an environment to run a Simple Test

1,385 views
Skip to first unread message

sandeep nimmagadda

unread,
Nov 3, 2008, 6:38:09 AM11/3/08
to googletes...@googlegroups.com

Hi all,

I'm presently working on Windows-XP and am totally new to the Google Test Framework.
I've been goin through the basics of it for some time and have understood well.
Now i want to run a sample test using the Framework Libraries or whatever.

I downloaded sample programs from the "downloads" section of the home page.

I'm working on Visual Studio. So how do I add what all header and library source files(i.e gtest.h.........or  any other) that are necessary for the tests to execute.
Is it like I just add the "gtest.h" file in the current project that i'm working......can't i make it as a dll file and use it ??
How do i set that up.


Sandeep

Vlad Losev

unread,
Nov 4, 2008, 1:09:08 PM11/4/08
to sandeep nimmagadda, googletes...@googlegroups.com
Hi Sandeep,

To use Google Test with Visual Studio, you need to do this:
  1. Open the msvc/gtest.sln solution. Agree to upgrade it if asked to.
  2. Create a console application project for your tests.
  3. Add gtest_main as a dependency for you project. The exact sequence for this varies with Visual Studio version. In VS 2005, right-click on you project, select Add Reference, then choose gtest_main in Projects tab.
  4. Add Google Test's include directory (<the directory where you have unpacked Google Test>/include) to your include path of your project.
  5. #include <gtest/gtest.h> into your test files.
After this you can write tests as explained in the Getting Started wiki page.

Hope this helps,
Vlad.

Jason

unread,
Nov 5, 2008, 4:53:30 PM11/5/08
to Google C++ Testing Framework
I followed these steps and had linker errors.

msvcprt.lib(MSVCP90.dll) : error LNK2005: "public: class
std::locale::facet * __thiscall std::locale::facet::_Decref(void)" (?
_Decref@facet@locale@std@@QAEPAV123@XZ) already defined in
gtest.lib(gtest.obj)

1>libcpmt.lib(ios.obj) : error LNK2005: "public: static void __cdecl
std::ios_base::_Addstd(class std::ios_base *)" (?
_Addstd@ios_base@std@@SAXPAV12@@Z) already defined in
msvcprt.lib(MSVCP90.dll)

40 errors noting various already defined messages.

Any ideas?

On Nov 4, 8:09 am, Vlad Losev <vl...@google.com> wrote:
> Hi Sandeep,
>
> To use Google Test with Visual Studio, you need to do this:
>
>    1. Open the msvc/gtest.sln solution. Agree to upgrade it if asked to.
>    2. Create a console application project for your tests.
>    3. Add gtest_main as a dependency for you project. The exact sequence for
>    this varies with Visual Studio version. In VS 2005, right-click on you
>    project, select Add Reference, then choose gtest_main in Projects tab.
>    4. Add Google Test's include directory (<the directory where you have
>    unpacked Google Test>/include) to your include path of your project.
>    5. #include <gtest/gtest.h> into your test files.
>
> After this you can write tests as explained in the Getting
> Started<http://code.google.com/p/googletest/wiki/GoogleTestPrimer>wiki
> page.
>
> Hope this helps,
> Vlad.
>

Vlad Losev

unread,
Nov 5, 2008, 9:58:13 PM11/5/08
to sandeep nimmagadda, clarkjas
This is actually a known bug in release 1.0.1. Please use release 1.1.0.

- Vlad.

On Tue, Nov 4, 2008 at 10:31 PM, sandeep nimmagadda <sande...@gmail.com> wrote:
Hi Vlad,

Thanks for the reply....I'm encountering problems when i proceeded the above way.....

1.  Upgradation of msvc/gtest.sln is producing 2 warnings for each individual project in it.....Later when i run the entire project I am getting 
     errors......I attached the output file for reference.....
2.  How do I add the Google Test's include directory (<the directory where you have unpacked Google Test>/include) to the include path of 
     my project. Is it just copying the include folder to my Project main folder ?? or is it copying them into the main Visual Studio include 
     folder (for example in C:\msvs8.0\VC\atlmfc\include)...

Sandeep



Reply all
Reply to author
Forward
0 new messages