Author Topic: Using Google Test with C::B  (Read 6110 times)

Offline husamettinor

  • Single posting newcomer
  • *
  • Posts: 2
Using Google Test with C::B
« 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.
« Last Edit: January 06, 2017, 05:02:07 pm by husamettinor »

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • Travis build status
Re: Using Google Test with C::B
« Reply #1 on: January 07, 2017, 02:51:33 am »
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!]

Offline husamettinor

  • Single posting newcomer
  • *
  • Posts: 2
Re: Using Google Test with C::B
« Reply #2 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?

Offline stahta01

  • Lives here!
  • ****
  • Posts: 7588
    • My Best Post
Re: Using Google Test with C::B
« Reply #3 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

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

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