Note that there are some explanatory texts on larger screens.

plurals
  1. POUse Google Test from Qt in Windows
    primarykey
    data
    text
    <p>I have a simple test file, TestMe.cpp:</p> <pre><code>#include &lt;gtest/gtest.h&gt; TEST(MyTest, SomeTest) { EXPECT_EQ(1, 1); } int main(int argc, char **argv) { ::testing::InitGoogleTest(&amp;argc, argv); return RUN_ALL_TESTS(); } </code></pre> <p>I have Google Test built as a static library. (I can provide the makefile if it's relevant.)</p> <p>I can compile TestMe.cpp from a command-line with no problem:</p> <pre><code>g++ TestMe.cpp -IC:\gtest-1.5.0\gtest-1.5.0\include -L../gtest/staticlib -lgtest -o TestMe.exe </code></pre> <p>It runs as expected.</p> <p>However, I cannot get this to compile in Qt. My Qt project file, in the same directory:</p> <pre><code>SOURCES += TestMe.cpp INCLUDEPATH += C:\gtest-1.5.0\gtest-1.5.0\include LIBS += -L../gtest/staticlib -lgtest </code></pre> <p>This results in 17 "unresolved external symbol" errors related to gtest functions.</p> <p>I'm pulling my hair out here, as I'm sure it's something simple. Any ideas?</p> <p>Here are some of the external symbols that are undefined:</p> <pre><code>TestMe.obj:-1: error: unresolved external symbol "public: int __thiscall testing::UnitTest::Run(void)" (?Run@UnitTest@testing@@QAEHXZ) referenced in function _main TestMe.obj:-1: error: unresolved external symbol "public: static class testing::UnitTest * __cdecl testing::UnitTest::GetInstance(void)" (?GetInstance@UnitTest@testing@@SAPAV12@XZ) referenced in function _main TestMe.obj:-1: error: unresolved external symbol "void __cdecl testing::InitGoogleTest(int *,char * *)" (?InitGoogleTest@testing@@YAXPAHPAPAD@Z) referenced in function _main TestMe.obj:-1: error: unresolved external symbol "public: __thiscall testing::internal::AssertHelper::~AssertHelper(void)" (??1AssertHelper@internal@testing@@QAE@XZ) referenced in function "private: virtual void __thiscall MyTest_SomeTest_Test::TestBody(void)" (?TestBody@MyTest_SomeTest_Test@@EAEXXZ) </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload