Code::Blocks Forums

User forums => Using Code::Blocks => Topic started by: husamettinor on January 06, 2017, 02:32:40 pm

Title: Using Google Test with C::B
Post by: husamettinor on January 06, 2017, 02:32:40 pm
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.
Title: Re: Using Google Test with C::B
Post by: 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.
Title: Re: Using Google Test with C::B
Post by: husamettinor on January 20, 2017, 12:49:42 pm
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?
Title: Re: Using Google Test with C::B
Post by: stahta01 on January 20, 2017, 01:05:01 pm
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 (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.