0

I created C++ Dynamic Linked Library project, then I created Native Unit Test project. When I try to run a default empty test, I get the error: enter image description here

There is no .lib in the folder: enter image description here

Here's a barebones solution with the problem: https://github.com/KulaGGin/TestLibrary

KulaGGin
  • 943
  • 2
  • 12
  • 27
  • 1
    .dll files still have .lib files for linking. – ChrisMM Jun 22 '20 at 14:47
  • 1
    ***There is no .lib because it's a dll.*** This is incorrect. There is a `.lib` created for a native `dll` if you actually export a symbol. – drescherjm Jun 22 '20 at 14:48
  • @ChrisMM Not in my case, here's the folder, it isn't there: https://i.imgur.com/Ohc7Xdp.png – KulaGGin Jun 22 '20 at 14:49
  • Your code probably does not export a symbol. Did you use a macro that changes between `__declspec(dllexport)` and `__declspec(dllimport)` depending on if you are building the dll or using it? – drescherjm Jun 22 '20 at 14:49
  • Did you compile "TestLibrary" – ChrisMM Jun 22 '20 at 14:50
  • @drescherjm No. I'm new to this. I don't know what macro I am suppose to use. – KulaGGin Jun 22 '20 at 14:50
  • Related: [https://stackoverflow.com/questions/14980649/macro-for-dllexport-dllimport-switch](https://stackoverflow.com/questions/14980649/macro-for-dllexport-dllimport-switch) – drescherjm Jun 22 '20 at 14:51
  • @ChrisMM I build the solution. – KulaGGin Jun 22 '20 at 14:51
  • Do I need to dllexport my methods to unit test them? – KulaGGin Jun 22 '20 at 14:55
  • You likely need to export your methods for native `c++` to call the method from code that is not the dll itself. So yes. – drescherjm Jun 22 '20 at 16:20
  • What if I want to unit test not exported methods? Is there a framework for that? I'm reading different Stackoverflow questions, like this one: https://stackoverflow.com/questions/5496912/unit-testing-non-exported-classes-in-a-dll . But all of them are hacks and have drawbacks: long build times, polluting main project with test files, etc. – KulaGGin Jun 22 '20 at 17:10
  • No sure why you want a dll with no exports (I have never wanted to do that in the 25+ years I have been a native c++ windows developer) however maybe you want to compile the same code as a static library so you don't have to export anything. – drescherjm Jun 22 '20 at 17:20

0 Answers0