Google Test: error LNK2019: unresolved external symbol with Visual Studio 2013

前端 未结 4 2328
忘了有多久
忘了有多久 2021-02-14 10:53

I\'m trying to get my first ever unit test with Google Test framework + Visual Studio 2013.However I\'m hitting the below error and can\'t understand why.

4条回答
  •  我寻月下人不归
    2021-02-14 11:21

    The root cause is the project type is not set correctly.

    In this example, there are three projects:

    1. FirstGoogleTest, which is the testee. the class to be tested resides in here.
    2. googleTest, which is the google test framework
    3. MyMultiplier_UnitLevelTest, which is the ULT project that contains the tests.

    The root cause is "FirstGoogleTest" project's configuration Type was set to .exe, which is the same as the ULT project. so the ult test cannot get the externals from "FirstGoogleTest". After changing "FirstGoogleTest" configuration Type to Static library (.lib). the solution can be compiled correctly and the ULT runs fine.

提交回复
热议问题