1

When I test cpp file on window vscode by using gtest and gmock, I'm suffering from lots of errors..

So, I follow below guideline, https://medium.com/swlh/google-test-installation-guide-for-c-in-windows-for-visual-studio-code-2b2e66352456

but collect2.exe: error: ld returned 1 exit status occured.

enter image description here

But gtest works well on visual studio!! But it does not work on vscode like above picture.

How can I handle this issue? Also, I want to know how I can test cpp file in window vscode...

Gama11
  • 31,714
  • 9
  • 78
  • 100
SOHYEON
  • 21
  • 3
  • Possible duplicate https://stackoverflow.com/questions/62910867/how-to-run-tests-and-debug-google-test-project-in-vs-code – Dusan Todorovic Jun 19 '21 at 12:57
  • 1
    Does this answer your question? [How to run tests and debug Google Test project in VS Code?](https://stackoverflow.com/questions/62910867/how-to-run-tests-and-debug-google-test-project-in-vs-code) – Dusan Todorovic Jun 19 '21 at 12:57

1 Answers1

0

You have downloaded libgtest.a and libgtest_main.a libraries that are not suitable to your compiler. Use Google tests from sources from the official Google test repository to build your own libraries https://github.com/google/googletest/tree/release-1.11.0

IMHO the guide you used demonstrates bad practice with coping libraries and header files to the compiler directories.

273K
  • 29,503
  • 10
  • 41
  • 64