1

I am new to gtest and gmock but certainly finding it useful. Currently I have built gtest and wrote sample test cases and executed them to see a proper workflow of gtest.

As in my main usecase the library I want to unit test is a dll (dynamic linking library). Until now I have created the project as static library and and wrote unit test cases for the same and it works fine but when I build it as dll, visual studio gives me linker error while trying to find Calculator.lib. Shouldn't it find Calculator.dll in this case.

Why it is going to find the .lib ?I wonder how can I load dll to write unit test cases for ?

I am new to it, please pardon me for stupid question.

CMouse
  • 130
  • 3
  • 19
  • How did you build the dll? You can make it generate a lib file. How do you "link" the dll to the project? – doctorlove Sep 27 '17 at 12:04
  • I changed the configuration type to dll and voila ! its done ! and the linking part, how do I do it ? I am not sure, and that's what the question is @doctorlove – CMouse Sep 28 '17 at 05:00
  • Does this help? https://stackoverflow.com/questions/35668224/referencing-dll-from-one-project-in-another-in-visual-studio-2012 – doctorlove Sep 28 '17 at 08:48
  • Ye it does, Thanks ! The problem is I cannot find the .lib file corresponding to the .dll, of course I can see the .obj but no .lib. How do I generate the .lib along with .dll ? @doctorlove – CMouse Sep 28 '17 at 09:14

1 Answers1

2

Pulling together the comments,

export symbols

when you make the dll.

When you build the dll you will also get a lib file.

Then as you can use Linker->Input->Additional Dependencies and add the name of the .lib file.

This will pick up the exported symbols: make sure you actually export things to use them.

doctorlove
  • 18,872
  • 2
  • 46
  • 62