Connexion rapide:  

Forum: VirtualDJ Plugins

Sujet Process to generate .dll for PC
djcelPRO InfinityModeratorMember since 2004
An example to build a C++ DLL with Visual Studio (Community) 2022 by using this example Audio Plugin (DSP) using SDK v8 (it mutes the sound on the left channel)

Let's say "dev" is your development folder for this example.

---------------------------------------------------------------------------------------------------------------------------------------------------
Create your first C++ DLL project with Visual Studio (Community) 2022
---------------------------------------------------------------------------------------------------------------------------------------------------

  1. Download and install Visual Studio (Community) 2022. You need at least to select and install "Desktop development with C++" in the Visual Studio Installer (you can use "Modify" to add packages in the future)
  2. In Visual Studio, click on "Create a new project"
  3. Select the filter: "C++", "Windows", "Library"
  4. Select "Dynamic-Link Library (DLL)" , then click on the "Next button'
  5. In the new window, name the project "Test1" for example, select your development folder "dev" and check the box "Place solution and project in the same directory". Click on the "Create" button.
  6. Visual Studio creates the solution.
  7. Select the "Release" mode instead of "Debug" (as we know the Microsoft code is already ok)
  8. "x64" option is to build a 64bit DLL whereas "x86" (ie "Win32") will create a 32bit DLL
  9. You can click in the "Build" menu on "Build solution" to compile your first DLL (the Microsoft example)

Note 1:
To add a new file to the project, in the "Solution Explorer" of Visual Studio, right click on the "Source files" or "Header files" folder, then "Add" --> "New Item..." (.h in Header files and .cpp in Source files)

Note 2:
To open your project when Visual Studio is closed, click on the "Plugin.sln" solution file.

Note 3:
You can find the "Plugin.dll" file in the folder "dev\Plugin\x64\Release" for x64 and in the "dev\Plugin\Release" folder for x86.

---------------------------------------------------------------------------------------------------------------------------------------------
Now we are going to create a new project to make a VirtualDJ plugin
---------------------------------------------------------------------------------------------------------------------------------------------

  1. In Visual Studio, click on "Create a new project"
  2. Select the filter: "C++", "Windows", "Library"
  3. Select "Windows Desktop Wizard" , then click on the "Next" button
  4. In the new window, name the project "Plugin" for example, select your development folder ("dev") and check "Place solution and project in the same directory". Click on "Create"
  5. In the new window,
    • for "Application type", select "Dynamic-Link Library (DLL)"
    • check "Empty Project"

  6. Visual Studio creates the solution.
  7. Select the "Release" mode instead of "Debug"
  8. "x64" option is to build a 64bit DLL whereas the other option will create a 32bit DLL
  9. First, save the following files (the VirtualDJ SDK), downloaded or code copied from the VirtualDJ website, in the "dev/Plugin" folder :
    • vdjPlugin8.h
    • vdjDsp8.h

  10. Then, save the following files, code copied from the VirtualDJ website (please refer to the example), in the "dev/Plugin" folder :
    • Main.cpp
    • MyPlugin8.h
    • MyPlugin8.cpp

  11. In the "Solution Explorer" of Visual Studio, right click on the "Source files" or "Header files" folder, then "Add" --> "Existing Item..." or use "New Item..." to add the 5 files listed above (.h in Header files and .cpp in Source files)
  12. Then you can build the solution without errors (just 2 warnings that we are going to hide in the next steps)


Note 1:
We advise you to create 2 subfolders "PC" with project files and "src" with your .cpp and .h files. So you could use the same "src" folder for your Mac project.

Note 2:
You can add a ressource file in your project to add a version or bitmap/xml files to your DLL (usefull for advanced plugin GUI). It will create "Plugin.rc" and "resource.h" files.

Note 3:
By default, the Unicode (UTF-16 / UTF-32) text format is selected in the project properties. You can change it if you want to work with UTF-8 / ASCII text format.

----------------------------------------------------------------------
Project properties adjustments
----------------------------------------------------------------------
  • Warning 1 wrote :
    warning LNK4104: export of symbol 'DllGetClassObject' should be PRIVATE
    can be removed by adding the following code in the additional option of the Linker
    /IGNORE:4104

  • Warning 2 wrote :
    Previous IPDB not found, fall back to full compilation.
    All 25 functions were compiled because no usable IPDB/IOBJ from previous compilation was found
    can be removed in "Linker" --> "Optimization" --> "Link Time Code Generation": "Use Link Time Code Generation (/LTCG)" instead of "Use Fast Link Time Code Generation (/LTCG:incremental)"

  • We also advise you to make this change for "C/C++" --> "Code Generation" --> "Runtime Library" : switch to "Multi-threaded (/MT)" instead of "Multi-threaded DLL (/MD)". It's better when you share a DLL with someone else (link to CRT). External libs should also be built with runtime libraries MT. For more information, search on the Internet for the difference between /MT and /MD.

  • If you have selected "precompiled header", you can remove this option by doing so:

    1. in the "Solution Explorer", right click on "Plugin" (and not "Solution ' Plugin' ") and select "Properties". It opens a new window with many options (don't worry, we are going to help you)
    2. First, for "Configuration", select "Release" instead of "Debug" (but you need to modify both)
    3. Then go to the "C/C++" folder in the tree
    4. Click on the "Precompiled Headers" line in the tree
      (i) Select "Not using Precompiled Headers" for the first option "Precompiled Header"
      (ii) Remove "pch.h" for the second option "Precompiled Header File"
      (iii) Remove "$(IntDir)$(TargetName).pch" for the third option "Precompiled Header Output File"
    5. Click on "OK"

 

Posté Sat 19 Nov 22 @ 6:23 pm