error LNK2019: unresolved external symbol NvAPI_GPU_GetThermalSettings referenced in

3.4k views Asked by At

I'm trying to write a simple code for getting some information from my GPU (NVidia Geforce 760 GTX) such as temperature using NVAPI.
I started with CUDA sample codes. Maybe you see these sample codes provided by NVidia. I copied one of the sample codes ('CUDA Samples\v6.5\0_Simple\vectorAdd') to write in this sample. I copied all of '.h' files of NVAPI to 'CUDA Samples\v6.5\common\inc' and copied 'nvapi.lib' to 'CUDA Samples\v6.5\common\lib\Win32' and copied 'nvapi64.lib' to 'CUDA Samples\v6.5\common\lib\x64'.
I preformed these copies to 'C:\Program Files\CUDA\v6.5\include' and 'C:\Program Files\CUDA\v6.5\lib'.
This is the code I wrote:

int _txmain() {

NvAPI_Status ret = NVAPI_OK;
int i=0;

NvDisplayHandle hDisplay_a[NVAPI_MAX_PHYSICAL_GPUS*2] = {0};

ret = NvAPI_Initialize();

if (!ret == NVAPI_OK){
    NvAPI_ShortString string;
    NvAPI_GetErrorMessage(ret, string);
    printf("NVAPI NvAPI_Initialize: %s\n", string);
}

NvAPI_ShortString ver;

NvAPI_GetInterfaceVersionString(ver);
printf("NVAPI Version: %s\n", ver);

NvU32 cnt;

NvPhysicalGpuHandle phys;

ret = NvAPI_EnumPhysicalGPUs(&phys, &cnt);

if (!ret == NVAPI_OK){
    NvAPI_ShortString string;
    NvAPI_GetErrorMessage(ret, string);
    printf("NVAPI NvAPI_EnumPhysicalGPUs: %s\n", string);
}

NvAPI_ShortString name;

NV_GPU_THERMAL_SETTINGS thermal;

ret = NvAPI_GPU_GetFullName(phys, name);
if (!ret == NVAPI_OK){
    NvAPI_ShortString string;
    NvAPI_GetErrorMessage(ret, string);
    printf("NVAPI NvAPI_GPU_GetFullName: %s\n", string);
}

printf("Name: %s\n", name);
thermal.version =NV_GPU_THERMAL_SETTINGS_VER;
ret = NvAPI_GPU_GetThermalSettings(phys,0, &thermal);

if (!ret == NVAPI_OK){
    NvAPI_ShortString string;
    NvAPI_GetErrorMessage(ret, string);
    printf("NVAPI NvAPI_GPU_GetThermalSettings: %s\n", string);
}

printf("Temp: %l C\n", thermal.sensor[0].currentTemp);

return 0;

}

But when I build my code I received these errors:

Error 28 error LNK2019: unresolved external symbol NvAPI_GPU_GetThermalSettings referenced in function...
Error 29 error LNK2019: unresolved external symbol NvAPI_GPU_GetFullName referenced in function...
and some similar errors.

1

There are 1 answers

0
Biswajeet Datta On

You need to goto your Project properties and expand Linker option -> Input and add the required nvapi*.lib file in Additional dependencies option.