3

I need to create dll library from existing c++ project (around 20 files .cpp and .h). Project use opencv. I've done something like this:

#ifndef TESTDLL_LOADCONFIG_H
#define TESTDLL_LOADCONFIG_H __declspec(dllexport)
#else   
#define TESTDLL_LOADCONFIG_H __declspec(dllimport)
#endif

at the beginning every header file which I want to export. And changed in properties configuration type to dll.

So there is my question is it all, and build dll file is ok? And is it possible to not attach again a opencv if it was attached in first project?

Przemekeke
  • 81
  • 10
  • ***So there is my question is it all, and build dll file is ok?*** Your macro is wrong. `TESTDLL_LOADCONFIG_H` should be different from the macro defined as `__declspec(dllexport)` or `__declspec(dllimport)` – drescherjm Aug 02 '16 at 13:28
  • ***And is it possible to not attach again a opencv if it was attached in first project?*** What do you mean attach `opencv`? – drescherjm Aug 02 '16 at 13:29
  • I mean that in my project I had to add a opencv .dll and .lib files and also add path to additional includes. So I'm asking if I need to do the same in my next project which will use my dll. – Przemekeke Aug 02 '16 at 13:32
  • If the next project needs to directly use opencv classes you will need to include and link to it. If all of your opencv is hidden inside your `dll` and not exposed at all to the other project then no you don't need to include or link to opencv in the other project. Also even with your `dll` you will have to make sure the opencv dlls are in the path of the new project so that they are available for execution. – drescherjm Aug 02 '16 at 13:35
  • Thanks guys I'll try one more time – Przemekeke Aug 02 '16 at 13:55
  • BTW: Here is the correct usage of the dll macro: http://stackoverflow.com/questions/14980649/macro-for-dllexport-dllimport-switch Make sure `COMPILING_DLL` is defined only when you build the dll. – drescherjm Aug 02 '16 at 13:58

0 Answers0