Build Applications with the AFX SDK#
The SDK includes dependent libraries in external/cuda/lib, which are required to compile and run applications and do not require libraries to be separately installed. Refer to Software Requirements (Windows) or Software Requirements (Linux) for runtime requirements for applications that use the SDK.
Windows#
To build applications with SDK on Windows, use one of the following methods:
Statically link the library in Visual Studio by using the
.libfile (NVAudioEffects.lib).For more information, refer to Build the Sample Application.
Load the SDK DLL at runtime by using
LoadLibrary/GetProcAddress.For example, NvAFX_CreateEffect can be called in the following way:
typedef NvAFX_Status(*NVAFX_CREATEEFFECT)(NvAFX_EffectSelector, NvAFX_Handle*); HINSTANCE h = LoadLibraryW(L"NVAudioEffects.dll"); NvAFX_CreateEffect = (NVAFX_CREATEEFFECT)GetProcAddress(h, "NvAFX_CreateEffect"); void *nv_handle; NvAFX_CreateEffect("denoiser", &nv_handle); // Similarly for other APIs FreeLibrary(h);
Previous releases of TensorRT might have a bug where cuBLAS is not unloaded after you unload the SDK DLL, and this issue might cause a memory leak.
To work around this issue, run the following workaround:
int maxLoopCount = 5;
while (maxLoopCount--) {
HMODULE cublas_handle = GetModuleHandleW(L"cublasLt64_11");
if (!cublas_handle) break;
if (FreeLibrary(cublas_handle) == false) break;
}
Linux#
To build applications with SDK on Linux, use one of the following methods:
At compile time, link to the core SDK library,
libnv_audiofx.so. For example, withgcc:gcc -L "../../nvafx/lib" -l "nv_audiofx" -L "../../external/cuda/lib/" -I "../../nvafx/include" source.c
Dynamically load the core SDK library,
libnv_audiofx.so, by usingdlopen/dlsymwith the correct library paths set (viaLD_LIBRARY_PATHor similar). For more information, refer to thedlopen(3)/dlsym(3)man pages.For example:
// Typedefs for functions; similarly define for other functions required typedef NvAFX_Status (*fnNvAFX_CreateEffect)(NvAFX_EffectSelector code, NvAFX_Handle* effect); // Load library and bind // Note: ensure that external/cuda/lib is in library path, or fix via RPATH/similar void* handle = dlopen("libnv_audiofx.so", RTLD_LAZY); assert(handle); fnNvAFX_CreateEffect f = (fnNvAFX_CreateEffect) dlsym(handle, "NvAFX_CreateEffect"); assert(f); // Call functions NvAFX_Handle effect; auto ret = f(NVAFX_EFFECT_DENOISER, &effect); assert(ret == NVAFX_STATUS_SUCCESS);