News:

The new Release 25.03 is out! You can download binaries for Windows and many major Linux distros here .

Main Menu

Using Google Test with C::B

Started by husamettinor, January 06, 2017, 02:32:40 PM

Previous topic - Next topic

husamettinor

Hello everyone,

I have a basic problem with using google test framework with Code::Blocks on Windows. I've searched but couldn't find needed steps on the internet. I have included needed paths and libgtest.a but still have undefined reference errors whenever I am trying to run.

//
#include "gtest/gtest.h"

int main(int argc, char **argv) {
  ::testing::InitGoogleTest(&argc, argv);
  return RUN_ALL_TESTS();
}
//

I run this code and got the messages,

obj\Debug\main.o||In function `main':|
C:\Users\Merve\Desktop\Dummy\main.cpp|4|undefined reference to `testing::InitGoogleTest(int*, char**)'|
obj\Debug\main.o||In function `Z13RUN_ALL_TESTSv':|
C:\googletest\include\gtest\gtest.h|2233|undefined reference to `testing::UnitTest::GetInstance()'|
C:\googletest\include\gtest\gtest.h|2233|undefined reference to `testing::UnitTest::Run()'|

Thanks.

oBFusCATed

You have to link to the library or add the library cpp files to your project.
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

husamettinor

Quote from: oBFusCATed on January 07, 2017, 02:51:33 AM
You have to link to the library or add the library cpp files to your project.

I did but still have the same problem. Can you explain step by step?

stahta01

Quote from: husamettinor on January 20, 2017, 12:49:42 PM
Quote from: oBFusCATed on January 07, 2017, 02:51:33 AM
You have to link to the library or add the library cpp files to your project.

I did but still have the same problem. Can you explain step by step?

Post the current full "Build Log" or most of us will just ignore you.
http://wiki.codeblocks.org/index.php/FAQ#Compiling_.28errors.29

ALSO WHEN REPLYING TO AN EITHER OR DIRECTIONS: State what option you followed!!

Tim S.
C Programmer working to learn more about C++.
On Windows 10 64 bit and Windows 11 64 bit.
--
When in doubt, read the CB WiKi FAQ. [url="http://wiki.codeblocks.org"]http://wiki.codeblocks.org[/url]