Linking error LNK2019 - GTest 1.7.0

816 views
Skip to first unread message

William Paiva

unread,
Feb 11, 2014, 6:31:41 AM2/11/14
to googletes...@googlegroups.com
Hi sirs,

My problem is: 

Every time I try to test a method that is defined in a .cpp file I get the following error:
error LNK2019: unresolved external symbol "public: void __thiscall utils::Utils::maskIP(char const *,char *)" (?maskIP@Utils@utils@@QAEXPBDPAD@Z) referenced in function "private: virtual void __thiscall UtilsTest_testMaskIP_Test::TestBody(void)" (?TestBody@UtilsTest_testMaskIP_Test@@EAEXXZ) C:\Users\william\Documents\Visual Studio 2010\Projects\UtilsTest\UtilsTest.obj

However, when I define the method as inline (within the .h file) the test runs ok. Where is my error?

My setup:

Visual Studio 2010
GTest 1.7.0
/MTd (both projects)
Test project with dependency to the main project
Test project with dependency libs GTests (gtestd.lib and gtest_maind.lib).

Best regards

Billy Donahue

unread,
Feb 11, 2014, 10:16:39 AM2/11/14
to William Paiva, Google C++ Testing Framework
It sounds like you forgot to link Utils.obj (or whatever it's called) into your test program.



--
 
---
You received this message because you are subscribed to the Google Groups "Google C++ Testing Framework" group.
To unsubscribe from this group and stop receiving emails from it, send an email to googletestframe...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

William Paiva

unread,
Feb 11, 2014, 1:16:45 PM2/11/14
to googletes...@googlegroups.com, William Paiva
The fact of I add a dependency of the main project wouldn't solve this?
To unsubscribe from this group and stop receiving emails from it, send an email to googletestframework+unsub...@googlegroups.com.

Billy Donahue

unread,
Feb 11, 2014, 1:27:00 PM2/11/14
to William Paiva, Google C++ Testing Framework
That should solve it, if the .cpp and the .h agree on the exact definition of utils::Utils::maskIP.
Anyway, can you agree that your problem is not a googletest framework problem?
You're struggling with getting your linker to see your library somehow. Hard to diagnost remotely.
Good luck with it.


To unsubscribe from this group and stop receiving emails from it, send an email to googletestframe...@googlegroups.com.

William Paiva

unread,
Feb 11, 2014, 2:26:00 PM2/11/14
to googletes...@googlegroups.com, William Paiva
Ok, thanks!
To unsubscribe from this group and stop receiving emails from it, send an email to googletestframework+unsubscribe...@googlegroups.com.

For more options, visit https://groups.google.com/groups/opt_out.
Reply all
Reply to author
Forward
0 new messages