@@ -564,7 +564,7 @@ project(HelloDiligent CXX)
564564add_subdirectory(DiligentCore)
565565
566566add_executable(HelloDiligent WIN32 HelloDiligent.cpp)
567- target_compile_options(HelloDiligent PRIVATE -DUNICODE -DENGINE_DLL )
567+ target_compile_options(HelloDiligent PRIVATE -DUNICODE)
568568
569569target_link_libraries(HelloDiligent
570570PRIVATE
@@ -582,6 +582,28 @@ Please also take a look at getting started tutorials for
582582[ Windows] ( https://github.com/DiligentGraphics/DiligentSamples/tree/master/Tutorials/Tutorial00_HelloWin32 ) and
583583[ Linux] ( https://github.com/DiligentGraphics/DiligentSamples/tree/master/Tutorials/Tutorial00_HelloLinux ) .
584584
585+ #### Static vs Dynamic Linking
586+
587+ On most platforms, core engine libraries are built in both static and dynamic versions
588+ (for example, ` Diligent-GraphicsEngineD3D12-static ` and ` Diligent-GraphicsEngineD3D12-shared ` ).
589+ You can choose which version to link with by changing the target name in ` target_link_libraries() ` CMake command.
590+ When linking with dynamic libraries, the ` ENGINE_DLL ` macro will be defined, and the libraries will need to be loaded
591+ at runtime. For example, for Direct3D12 backend:
592+
593+ ``` cpp
594+ #if ENGINE_DLL
595+ // Load the dll and import GetEngineFactoryD3D12() function
596+ auto GetEngineFactoryD3D12 = LoadGraphicsEngineD3D12();
597+ #endif
598+ auto * pFactoryD3D12 = GetEngineFactoryD3D12();
599+ ```
600+
601+ When using static linking, the ` ENGINE_DLL ` macro will not be defined, and the ` GetEngineFactoryD3D12 ` function will be
602+ statically linked with the executable.
603+
604+ [ SampleApp.cpp] ( https://github.com/DiligentGraphics/DiligentSamples/blob/master/SampleBase/src/SampleApp.cpp ) file provides
605+ an example of how to initialize the engine on different platforms using static or dynamic linking.
606+
585607#### Using FetchContent
586608
587609You can use [ FetchContent] ( https://cmake.org/cmake/help/latest/module/FetchContent.html ) to download Diligent Engine modules.
0 commit comments