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
---------------------------------------------------------------------------------------------------------------------------------------------------
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
---------------------------------------------------------------------------------------------------------------------------------------------
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
----------------------------------------------------------------------
Let's say "dev" is your development folder for this example.
---------------------------------------------------------------------------------------------------------------------------------------------------
Create your first C++ DLL project with Visual Studio (Community) 2022
---------------------------------------------------------------------------------------------------------------------------------------------------
- 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)
- In Visual Studio, click on "Create a new project"
- Select the filter: "C++", "Windows", "Library"
- Select "Dynamic-Link Library (DLL)" , then click on the "Next button'
- 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.
- Visual Studio creates the solution.
- Select the "Release" mode instead of "Debug" (as we know the Microsoft code is already ok)
- "x64" option is to build a 64bit DLL whereas "x86" (ie "Win32") will create a 32bit DLL
- 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
---------------------------------------------------------------------------------------------------------------------------------------------
- In Visual Studio, click on "Create a new project"
- Select the filter: "C++", "Windows", "Library"
- Select "Windows Desktop Wizard" , then click on the "Next" button
- 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"
- In the new window,
- for "Application type", select "Dynamic-Link Library (DLL)"
- check "Empty Project"
- Visual Studio creates the solution.
- Select the "Release" mode instead of "Debug"
- "x64" option is to build a 64bit DLL whereas the other option will create a 32bit DLL
- 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
- 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
- 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)
- 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 :can be removed by adding the following code in the additional option of the Linkerwarning LNK4104: export of symbol 'DllGetClassObject' should be PRIVATE
/IGNORE:4104
- Warning 2 wrote :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)"Previous IPDB not found, fall back to full compilation.
All 25 functions were compiled because no usable IPDB/IOBJ from previous compilation was found - 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:
- 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)
- First, for "Configuration", select "Release" instead of "Debug" (but you need to modify both)
- Then go to the "C/C++" folder in the tree
- 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" - Click on "OK"
Posted Sat 19 Nov 22 @ 6:23 pm