Using CVL in DLLs

You can build dynamic link libraries (DLLs) that use CVL routines. To create a standard C++ DLL, perform the following steps. These steps are not intended for use in “Mixed Mode” DLLs, that is, DLLs that mix .NET managed code with unmanaged C++ code.

When using your CVL-based DLLs, it is important that the main routine of your application links against cogstds.lib as described in Static Libraries. There are two cases to consider:

CASE A – Your main application (exe) uses CVL and its DLLs use CVL as well. Because your main application uses CVL directly, it will already include ch_cvl/defs.h. You can create your own DLL using these two steps:

  1. Define the symbol cmBuildingDLLs in your DLL project settings. To do this, display the Property Page for your project. Select the C/C++ folder, then the Preprocessor category. Add this symbol to the Preprocessor Definitions field.
  2. If a DLL will instantiate a ccWin32Display or ccDisplayConsole object, then your calling executable should run cfInitializeDisplayResources() in its startup code, as described further in Calling CVL Display API from Your Own DLL.

CASE B – Your main application (exe) does not use CVL but its DLLs do use CVL:

  1. Define the symbol cmBuildingDLLs in your DLL project settings. To do this, display the Property Page for your project. Select the C/C++ folder, then the Preprocessor category. Add this symbol to the Preprocessor Definitions field.
  2. Link applications that use your DLL with the appropriate version of cogstds.lib, which contains CVL initialization code. You can do this in the following ways:
    • Simple method:
      Include ch_cvl/defs.h in the main application. This is for the linker, not the compiler. Note that this includes all the lines from the header file. Your application will not need most of these lines, but they should be harmless. If you do not want to include the entire header, use the method below.
    • Other method:
      Add the following preprocessor directives to your main application (Visual C++ .NET 2012 32-bit shown):
    • #ifndef cmBuildingDLLs
      #pragma comment(linker, "/include:_cgLoadHardwareSupport")
      #pragma comment(linker, "/include:_cgYankCVTShutdown")
      #ifdef _DEBUG
      #ifdef _UNICODE
      #pragma comment(lib, "cogstds11ud.lib")
      #else
      #pragma comment(lib, "cogstds11d.lib")
      #endif
      #else
      #ifdef _UNICODE
      #pragma comment(lib, "cogstds11u.lib")
      #else
      #pragma comment(lib, "cogstds11.lib")
      #endif
      #endif
      #endif

      If you are using Visual C++ .NET, 2013, append “12” instead of “11” to the cogstds basename for each of the library names, calling the following four libraries instead:

      cogstds12ud.lib
      cogstds12d.lib
      cogstds12u.lib
      cogstds12.lib

      For Visual C++ .NET, 2015, append “14”.

      If you are using Visual C++ .NET, 2012 64-bit, call the following four libraries:

      cogstds11_x64ud.lib
      cogstds11_x64d.lib
      cogstds11_x64u.lib
      cogstds11_x64.lib

      See Static Libraries for a discussion of the purpose of the cogstds.lib library.

  3. If a DLL will instantiate a ccWin32Display or ccDisplayConsole object, then your calling executable should run cfInitializeDisplayResources() in its startup code, as described further in Calling CVL Display API from Your Own DLL.