Follow these steps in order!
0) Install the build tools, first!
1) About the QMake tool:
DAZ Studio SDK is tightly integrated with the Qt4 graphical user interface library. DAZ created their own variant of Qt4, under C:\Users\Public\Documents\My DAZ 3D Library
There are some important subdirectories here: /bin, /include, /lib, /docs, and /sample.
The /bin subdirectory contains the qmake.exe tool. This tool integrates the Qt4 libraries and other tools, by virtue of qmake.exe being placed in this subdirectory.
Hence, qmake.exe must be found as part of the Windows 11 system PATH environment variable. Right-click on qmake.exe, copy the path to this, and edit the system PATH environment variable by pasting the copied path.
The behavior of qmake.exe is somewhat inflexible. DAZ's version was rebuilt in house to point to paths not existing in any other programmer's world. To redress this (and I learned how to do this after tearing my hair out for a week!), a configuration file must be placed in the /bin directory so that qmake.exe can read it for the actual path needed. The contents are simple. create and edit using a conventional text editor such as Notepad:
We will use relative path addressing so that get qmake.exe to point to the top of the file hierarchy that we want (which by no coincidence is C:\Users\Public\Documents\My DAZ 3D Library).
Once qmake.exe can be found by the system path, and qt.conf is properly installed, use "qmake -query" to verify that QT_INSTALL_PREFIX is at C:\Users\Public\Documents\My DAZ 3D Library)
==== qt.conf ====
[Paths]
Prefix = "../../.."
==== qt.conf ====
QMake also needs an environment variable to override its own behavior when determining the top of its own tools hierarchy, so add the environment variable:
QMAKESPEC, set to C:\Users\Public\Documents\My DAZ 3D Library\DAZStudio4.5+ SDK\
2) About the CMake tool:
DAZ no longer uses the VS 2010 build system directly. Instead, DAZ redesigned the project around CMake to generate a project file hierarchy for VS 2010 to read. CMake reads a package description file, CMakeLists.txt, to generate project and solution files for VS2010, as well as the resource files essential for the graphical user interface plugin application library we are building for dropping into DAZ Studio.
The plugin to be built is AFirstPlugin, which is a Hello World example to be run from DAZ Studio, and provided by DAZ as the sample project directory C:\Users\Public\Documents\My DAZ 3D Library\DAZStudio4.5+ SDK\samples\interface\AFirstPlugin
For expediency we run the CMake tool, cmake.exe, directly from where you install it (this will be improved later) such as "./cmake.exe -G "Visual Studio 10" "C:\Users\Public\Documents\My DAZ 3D Library\DAZStudio4.5+ SDK\samples\interface\AFirstPlugin\CMakeLists.txt"
CMake will use the CMakeLists.txt package file to create the necessary Visual Studio 10 project files, solution files, and resource files which AFirstPlugin needs to successfully compile and link.
For the above command to work, modifications A through F need to be made first:
A) In the AFirstPlugin directory, CMake needs to know where the Qt4 library resides on the system, to override qmake.exe's own idea where said library resides which was baked in during QMake's building by DAZ. And so, we place the file qmake.conf in this directory.
===== qmake.conf =====
QT_INSTALL_LIBS = "C:\\Users\\Public\\Documents\\My DAZ 3D Library\\DAZStudio4.5+ SDK\\lib\\"
====================
B) In the AFirstPlugin directory, the CMakeLists.txt needs to be modified to provide paths overriding QMake's own idea of where Qt build tools and resources resides which was baked in during QMake's own building by DAZ. And so, we insert lines at the top of CMakeLists.txt for this project which will set these values from system environment variables, utilizing the "set" and the "markasadvanced" commands.
C) Further, CMake requires a kick-start to initiate the search for Qt Core library components, which is missing in the original file CMakeList.txt, and so we add a "find_package" command with the lines to insert.
===== insert at top of CMakeLists.txt after banner =====
if(DEFINED ENV{DAZ_MOC_EXECUTABLE})
set(QTMOCEXECUTABLE "$ENV{DAZ_MOC_EXECUTABLE}" CACHE PATH "DAZ base directory location (optional, used for nonstandard installation paths)" FORCE)
markasadvanced(QT_MOC_EXECUTABLE)
endif()
if(DEFINED ENV{DAZ_RCC_EXECUTABLE})
set(QTRCCEXECUTABLE "$ENV{DAZ_RCC_EXECUTABLE}" CACHE PATH "DAZ base directory location (optional, used for nonstandard installation paths)" FORCE)
markasadvanced(QT_RCC_EXECUTABLE)
endif()
if(DEFINED ENV{DAZ_CORE_INCLUDE_DIR})
set(QTCOREINCLUDEDIR "$ENV{DAZ_CORE_INCLUDE_DIR}" CACHE PATH "DAZ base directory location (optional, used for nonstandard installation paths)" FORCE)
markasadvanced(QT_CORE_INCLUDE_DIR)
endif()
if(DEFINED ENV{DAZ_CORE_LIBRARY})
set(QTCORELIBRARY "$ENV{DAZ_CORE_LIBRARY}" CACHE PATH "DAZ base directory location (optional, used for nonstandard installation paths)" FORCE)
markasadvanced(QT_CORE_LIBRARY)
endif()
find_package(Qt4 COMPONENTS Core)
=================================
D) Add the following environment variables for CMakeLists.txt changes to read from:
DAZ_CORE_INCLUDE_LIBRARY, set to C:\Users\Public\Documents\My DAZ 3D Library\DAZStudio4.5+ SDK\include
DAZ_CORE_LIBRARY, set to C:\Users\Public\Documents\My DAZ 3D Library\DAZStudio4.5+ SDK\lib\QtCore4.lib
DAZ_MOC_EXECUTABLE, set to C:\Users\Public\Documents\My DAZ 3D Library\DAZStudio4.5+ SDK\bin\moc.exe
DAZ_RCC_EXECUTABLE, set to C:\Users\Public\Documents\My DAZ 3D Library\DAZStudio4.5+ SDK\bin\rcc.exe
E) CMake itself also needs some environment variable overrides to get an idea of its own path for generating project files, so add the following:
CMAKE_PREFIX_PATH, set to C:\Users\Public\Documents\My DAZ 3D Library\DAZStudio4.5+ SDK\
CMAKE_ROOT, set to C:\Users\cmake\cmake-3.22.0-windows-i386\bin\
F) The QMake tool paths cannot individuate by operating system, even with the manual file and environment overrides given, and so the splitting by DAZ of the bin and lib subdirectories into Win32 and x64 is simply not going to work.
Since the use of 32 bit applications and libraries are obsolete on Windows 11, we will only build a plugin for the 64 bit DAZ Studio. Therefore:
Copy the contents of C:\Users\Public\Documents\My DAZ 3D Library\DAZStudio4.5+ SDK\lib\x64, to C:\Users\Public\Documents\My DAZ 3D Library\DAZStudio4.5+ SDK\lib
Copy the contents of C:\Users\Public\Documents\My DAZ 3D Library\DAZStudio4.5+ SDK\bin\x64, to C:\Users\Public\Documents\My DAZ 3D Library\DAZStudio4.5+ SDK\bin
3) About Visual Studio 2010 Ultimate:
Start up the application, Visual Studio 2010 Ultimate
Open the Solution file: C:\Users\Public\Documents\My DAZ 3D Library\DAZStudio4.5+ SDK\samples\interface\AFirstPlugin\Project.sln, that was generated in Step 2 by the CMake/QMake tools and the corrected file hierarchy.
Under the Properties menu of A First Plugin, Configuration Manager, set the Configuration drop down to All Platforms, and the Platform to Active(x64). All modifications to the Properties described below, should take place for All Platforms.
On the tools bar, set the current Solution Configuration to Debug, and the current Solution Platform to x64.
Under the Properties menu of A First Plugin, Linker section, the Target Machine should be set to MachineX64 (/MACHINE:X64)
Under the Properties menu of A First Plugin, Linker section, select Command Line, and examine the Additional Options window. REMOVE ANY MENTION OF X86 OR WINDOWS 32 ARCHITECTURES! This will help avoid machine conflicts during final linking of the plugin.
Try building. You may need to make the following corrections to your project:
Add the following to under the Properties menu of A First Plugin, C/C++ section, of Additional Include Directories:
C:\Users\Public\Documents\My DAZ 3D Library\DAZStudio4.5+ SDK\samples\interface\AFirstPlugin
C:\Users\Public\Documents\My DAZ 3D Library\DAZStudio4.5+ SDK\samples\interface\AFirstPlugin\sdkafirstpluginautogen\include_Debug
C:\Users\Public\Documents\My DAZ 3D Library\DAZStudio4.5+ SDK\include
C:\Users\Public\Documents\My DAZ 3D Library\DAZStudio4.5+ SDK\include\QtCore
Add the following to under the Properties menu of A First Plugin, Linker section, of Additional Library Directories:
C:\Users\Public\Documents\My DAZ 3D Library\DAZStudio4.5+ SDK\lib
Add the following to under the Properties menu of A First Plugin, Resource section, of Additional Library Directories:
C:\Users\Public\Documents\My DAZ 3D Library\DAZStudio4.5+ SDK\samples\interface\AFirstPlugin
C:\Users\Public\Documents\My DAZ 3D Library\DAZStudio4.5+ SDK\samples\interface\AFirstPlugin\sdkafirstpluginautogen\include_Debug
C:\Users\Public\Documents\My DAZ 3D Library\DAZStudio4.5+ SDK\include
Add the following to under the Properties menu of A First Plugin, Linker section, of Additional Dependencies:
QtScript4.lib
QtGui4.lib
QtCore4.lib
dzcore.lib
4) About DAZ Studio
Once you have a successful VS2010 build of A First Plugin, you will find it as C:\Users\Public\Documents\My DAZ 3D Library\DAZStudio4.5+ SDK\samples\interface\AFirstPlugin\Debug\sdk_afirstplugin.dll
Copy this sdk_afirstplugin.dll to C:\Program Files\DAZ 3D\DAZStudio4\plugins
Start DAZ Studio
On the Studio's main menu bar, to the right of the Help submenu, you will find a submenu labeled SDK Examples.
Click on the SDK Examples submenu.
The submenu will reveal a selection labeled "Hello"
Click on the "Hello" selection.
You will see a dialog, labelled, "A First Plugin: Dialog", with OK and Cancel buttons.
Congratulations! You just rebuilt a compiled DAZ Studio plugin using archived tools!
(NOTE: setting up for debugging the plugin, using the Just-In-Time debugging feature provided by Visual Studio 2010 ultimate, will be an exercise for the student.)
