Я пытаюсь использовать NVIDIA nvapi
и у меня есть ошибки компиляции, которые я не до конца понимаю. Возможно, я использую не тот компилятор?
#include "nvapi.h"#include <iostream>
int main()
{
printf("Hello nvapi!");
return 0;
}
Компиляция:
g++ nvapi_hello.cpp
Вывод (усеченный, потому что он был слишком длинным):
In file included from nvapi_lite_d3dext.h:35:0,
from nvapi.h:6,
from nvapi_hello.cpp:1:
nvapi_lite_salstart.h:821:41: warning: '__success' initialized and declared 'extern'
#define NVAPI_INTERFACE extern __success(return == NVAPI_OK) NvAPI_Status __cdecl
^
nvapi.h:99:1: note: in expansion of macro 'NVAPI_INTERFACE'
NVAPI_INTERFACE NvAPI_Initialize();
^~~~~~~~~~~~~~~
nvapi_lite_salstart.h:821:42: error: expected primary-expression before 'return'
#define NVAPI_INTERFACE extern __success(return == NVAPI_OK) NvAPI_Status __cdecl
^
nvapi.h:99:1: note: in expansion of macro 'NVAPI_INTERFACE'
NVAPI_INTERFACE NvAPI_Initialize();
^~~~~~~~~~~~~~~
nvapi_lite_salstart.h:821:41: warning: '__success' initialized and declared 'extern'
#define NVAPI_INTERFACE extern __success(return == NVAPI_OK) NvAPI_Status __cdecl
^
nvapi.h:134:1: note: in expansion of macro 'NVAPI_INTERFACE'
NVAPI_INTERFACE NvAPI_Unload();
^~~~~~~~~~~~~~~
nvapi_lite_salstart.h:821:41: error: redefinition of 'int __success'
#define NVAPI_INTERFACE extern __success(return == NVAPI_OK) NvAPI_Status __cdecl
^
nvapi.h:134:1: note: in expansion of macro 'NVAPI_INTERFACE'
NVAPI_INTERFACE NvAPI_Unload();
^~~~~~~~~~~~~~~
nvapi_lite_salstart.h:821:32: note: 'int __success' previously defined here
#define NVAPI_INTERFACE extern __success(return == NVAPI_OK) NvAPI_Status __cdecl
^
nvapi.h:99:1: note: in expansion of macro 'NVAPI_INTERFACE'
NVAPI_INTERFACE NvAPI_Initialize();
^~~~~~~~~~~~~~~
nvapi_lite_salstart.h:821:42: error: expected primary-expression before 'return'
#define NVAPI_INTERFACE extern __success(return == NVAPI_OK) NvAPI_Status __cdecl
^
nvapi.h:134:1: note: in expansion of macro 'NVAPI_INTERFACE'
NVAPI_INTERFACE NvAPI_Unload();
^~~~~~~~~~~~~~~
nvapi_lite_salstart.h:821:41: warning: '__success' initialized and declared 'extern'
#define NVAPI_INTERFACE extern __success(return == NVAPI_OK) NvAPI_Status __cdecl
^
nvapi.h:153:1: note: in expansion of macro 'NVAPI_INTERFACE'
NVAPI_INTERFACE NvAPI_GetErrorMessage(NvAPI_Status nr,NvAPI_ShortString szDesc);
^~~~~~~~~~~~~~~
nvapi_lite_salstart.h:821:41: error: redefinition of 'int __success'
#define NVAPI_INTERFACE extern __success(return == NVAPI_OK) NvAPI_Status __cdecl
^
nvapi.h:153:1: note: in expansion of macro 'NVAPI_INTERFACE'
NVAPI_INTERFACE NvAPI_GetErrorMessage(NvAPI_Status nr,NvAPI_ShortString szDesc);
^~~~~~~~~~~~~~~
nvapi_lite_salstart.h:821:32: note: 'int __success' previously defined here
#define NVAPI_INTERFACE extern __success(return == NVAPI_OK) NvAPI_Status __cdecl
^
nvapi.h:99:1: note: in expansion of macro 'NVAPI_INTERFACE'
NVAPI_INTERFACE NvAPI_Initialize();
^~~~~~~~~~~~~~~
nvapi_lite_salstart.h:821:42: error: expected primary-expression before 'return'
#define NVAPI_INTERFACE extern __success(return == NVAPI_OK) NvAPI_Status __cdecl
^
nvapi.h:153:1: note: in expansion of macro 'NVAPI_INTERFACE'
NVAPI_INTERFACE NvAPI_GetErrorMessage(NvAPI_Status nr,NvAPI_ShortString szDesc);
^~~~~~~~~~~~~~~
nvapi_lite_salstart.h:821:41: warning: '__success' initialized and declared 'extern'
#define NVAPI_INTERFACE extern __success(return == NVAPI_OK) NvAPI_Status __cdecl
^
nvapi.h:174:1: note: in expansion of macro 'NVAPI_INTERFACE'
NVAPI_INTERFACE NvAPI_GetInterfaceVersionString(NvAPI_ShortString szDesc);
^~~~~~~~~~~~~~~
nvapi_lite_salstart.h:821:41: error: redefinition of 'int __success'
#define NVAPI_INTERFACE extern __success(return == NVAPI_OK) NvAPI_Status __cdecl
^
nvapi.h:174:1: note: in expansion of macro 'NVAPI_INTERFACE'
NVAPI_INTERFACE NvAPI_GetInterfaceVersionString(NvAPI_ShortString szDesc);
^~~~~~~~~~~~~~~
nvapi_lite_salstart.h:821:32: note: 'int __success' previously defined here
#define NVAPI_INTERFACE extern __success(return == NVAPI_OK) NvAPI_Status __cdecl
^
nvapi.h:99:1: note: in expansion of macro 'NVAPI_INTERFACE'
NVAPI_INTERFACE NvAPI_Initialize();
^~~~~~~~~~~~~~~
nvapi_lite_salstart.h:821:42: error: expected primary-expression before 'return'
#define NVAPI_INTERFACE extern __success(return == NVAPI_OK) NvAPI_Status __cdecl
^
nvapi.h:174:1: note: in expansion of macro 'NVAPI_INTERFACE'
NVAPI_INTERFACE NvAPI_GetInterfaceVersionString(NvAPI_ShortString szDesc);
^~~~~~~~~~~~~~~
nvapi_lite_salstart.h:821:41: warning: '__success' initialized and declared 'extern'
#define NVAPI_INTERFACE extern __success(return == NVAPI_OK) NvAPI_Status __cdecl
^
nvapi.h:319:1: note: in expansion of macro 'NVAPI_INTERFACE'
NVAPI_INTERFACE NvAPI_GPU_GetEDID(NvPhysicalGpuHandle hPhysicalGpu, NvU32 displayOutputId, NV_EDID *pEDID);
^~~~~~~~~~~~~~~
nvapi_lite_salstart.h:821:41: error: redefinition of 'int __success'
#define NVAPI_INTERFACE extern __success(return == NVAPI_OK) NvAPI_Status __cdecl
^
nvapi.h:319:1: note: in expansion of macro 'NVAPI_INTERFACE'
NVAPI_INTERFACE NvAPI_GPU_GetEDID(NvPhysicalGpuHandle hPhysicalGpu, NvU32 displayOutputId, NV_EDID *pEDID);
^~~~~~~~~~~~~~~
nvapi_lite_salstart.h:821:32: note: 'int __success' previously defined here
#define NVAPI_INTERFACE extern __success(return == NVAPI_OK) NvAPI_Status __cdecl
^
nvapi.h:99:1: note: in expansion of macro 'NVAPI_INTERFACE'
NVAPI_INTERFACE NvAPI_Initialize();
^~~~~~~~~~~~~~~
nvapi_lite_salstart.h:821:42: error: expected primary-expression before 'return'
#define NVAPI_INTERFACE extern __success(return == NVAPI_OK) NvAPI_Status __cdecl
^
nvapi.h:319:1: note: in expansion of macro 'NVAPI_INTERFACE'
NVAPI_INTERFACE NvAPI_GPU_GetEDID(NvPhysicalGpuHandle hPhysicalGpu, NvU32 displayOutputId, NV_EDID *pEDID);
^~~~~~~~~~~~~~~
nvapi_lite_salstart.h:821:41: warning: '__success' initialized and declared 'extern'
#define NVAPI_INTERFACE extern __success(return == NVAPI_OK) NvAPI_Status __cdecl
^
nvapi.h:669:1: note: in expansion of macro 'NVAPI_INTERFACE'
NVAPI_INTERFACE NvAPI_SetView(NvDisplayHandle hNvDisplay, NV_VIEW_TARGET_INFO *pTargetInfo, NV_TARGET_VIEW_MODE targetView);
^~~~~~~~~~~~~~~
nvapi_lite_salstart.h:821:41: error: redefinition of 'int __success'
#define NVAPI_INTERFACE extern __success(return == NVAPI_OK) NvAPI_Status __cdecl
^
nvapi.h:669:1: note: in expansion of macro 'NVAPI_INTERFACE'
NVAPI_INTERFACE NvAPI_SetView(NvDisplayHandle hNvDisplay, NV_VIEW_TARGET_INFO *pTargetInfo, NV_TARGET_VIEW_MODE targetView);
^~~~~~~~~~~~~~~
nvapi_lite_salstart.h:821:32: note: 'int __success' previously defined here
#define NVAPI_INTERFACE extern __success(return == NVAPI_OK) NvAPI_Status __cdecl
^
nvapi.h:99:1: note: in expansion of macro 'NVAPI_INTERFACE'
NVAPI_INTERFACE NvAPI_Initialize();
^~~~~~~~~~~~~~~
nvapi_lite_salstart.h:821:42: error: expected primary-expression before 'return'
#define NVAPI_INTERFACE extern __success(return == NVAPI_OK) NvAPI_Status __cdecl
^
nvapi.h:669:1: note: in expansion of macro 'NVAPI_INTERFACE'
NVAPI_INTERFACE NvAPI_SetView(NvDisplayHandle hNvDisplay, NV_VIEW_TARGET_INFO *pTargetInfo, NV_TARGET_VIEW_MODE targetView);
^~~~~~~~~~~~~~~
nvapi_lite_salstart.h:821:41: warning: '__success' initialized and declared 'extern'
#define NVAPI_INTERFACE extern __success(return == NVAPI_OK) NvAPI_Status __cdecl
^
nvapi.h:808:1: note: in expansion of macro 'NVAPI_INTERFACE'
NVAPI_INTERFACE NvAPI_SetViewEx(NvDisplayHandle hNvDisplay, NV_DISPLAY_PATH_INFO *pPathInfo, NV_TARGET_VIEW_MODE displayView);
^~~~~~~~~~~~~~~
nvapi_lite_salstart.h:821:41: error: redefinition of 'int __success'
#define NVAPI_INTERFACE extern __success(return == NVAPI_OK) NvAPI_Status __cdecl
^
nvapi.h:808:1: note: in expansion of macro 'NVAPI_INTERFACE'
NVAPI_INTERFACE NvAPI_SetViewEx(NvDisplayHandle hNvDisplay, NV_DISPLAY_PATH_INFO *pPathInfo, NV_TARGET_VIEW_MODE displayView);
^~~~~~~~~~~~~~~
nvapi_lite_salstart.h:821:32: note: 'int __success' previously defined here
#define NVAPI_INTERFACE extern __success(return == NVAPI_OK) NvAPI_Status __cdecl
^
nvapi.h:99:1: note: in expansion of macro 'NVAPI_INTERFACE'
NVAPI_INTERFACE NvAPI_Initialize();
^~~~~~~~~~~~~~~
nvapi_lite_salstart.h:821:42: error: expected primary-expression before 'return'
#define NVAPI_INTERFACE extern __success(return == NVAPI_OK) NvAPI_Status __cdecl
^
nvapi.h:808:1: note: in expansion of macro 'NVAPI_INTERFACE'
NVAPI_INTERFACE NvAPI_SetViewEx(NvDisplayHandle hNvDisplay, NV_DISPLAY_PATH_INFO *pPathInfo, NV_TARGET_VIEW_MODE displayView);
^~~~~~~~~~~~~~~
nvapi_lite_salstart.h:821:41: warning: '__success' initialized and declared 'extern'
#define NVAPI_INTERFACE extern __success(return == NVAPI_OK) NvAPI_Status __cdecl
^
nvapi.h:1030:1: note: in expansion of macro 'NVAPI_INTERFACE'
NVAPI_INTERFACE NvAPI_GetDisplayDriverVersion(NvDisplayHandle hNvDisplay, NV_DISPLAY_DRIVER_VERSION *pVersion);
^~~~~~~~~~~~~~~
nvapi_lite_salstart.h:821:41: error: redefinition of 'int __success'
#define NVAPI_INTERFACE extern __success(return == NVAPI_OK) NvAPI_Status __cdecl
^
nvapi.h:1030:1: note: in expansion of macro 'NVAPI_INTERFACE'
NVAPI_INTERFACE NvAPI_GetDisplayDriverVersion(NvDisplayHandle hNvDisplay, NV_DISPLAY_DRIVER_VERSION *pVersion);
^~~~~~~~~~~~~~~
nvapi_lite_salstart.h:821:32: note: 'int __success' previously defined here
#define NVAPI_INTERFACE extern __success(return == NVAPI_OK) NvAPI_Status __cdecl
^
nvapi.h:99:1: note: in expansion of macro 'NVAPI_INTERFACE'
NVAPI_INTERFACE NvAPI_Initialize();
^~~~~~~~~~~~~~~
nvapi_lite_salstart.h:821:42: error: expected primary-expression before 'return'
#define NVAPI_INTERFACE extern __success(return == NVAPI_OK) NvAPI_Status __cdecl
^
nvapi.h:1030:1: note: in expansion of macro 'NVAPI_INTERFACE'
NVAPI_INTERFACE NvAPI_GetDisplayDriverVersion(NvDisplayHandle hNvDisplay, NV_DISPLAY_DRIVER_VERSION *pVersion);
^~~~~~~~~~~~~~~
nvapi_lite_salstart.h:821:41: warning: '__success' initialized and declared 'extern'
#define NVAPI_INTERFACE extern __success(return == NVAPI_OK) NvAPI_Status __cdecl
^
nvapi.h:1159:1: note: in expansion of macro 'NVAPI_INTERFACE'
NVAPI_INTERFACE NvAPI_OGL_ExpertModeSet(NvU32 expertDetailLevel,
^~~~~~~~~~~~~~~
nvapi_lite_salstart.h:821:41: error: redefinition of 'int __success'
#define NVAPI_INTERFACE extern __success(return == NVAPI_OK) NvAPI_Status __cdecl
^
nvapi.h:1159:1: note: in expansion of macro 'NVAPI_INTERFACE'
NVAPI_INTERFACE NvAPI_OGL_ExpertModeSet(NvU32 expertDetailLevel,
^~~~~~~~~~~~~~~
nvapi_lite_salstart.h:821:32: note: 'int __success' previously defined here
#define NVAPI_INTERFACE extern __success(return == NVAPI_OK) NvAPI_Status __cdecl
^
nvapi.h:99:1: note: in expansion of macro 'NVAPI_INTERFACE'
NVAPI_INTERFACE NvAPI_Initialize();
^~~~~~~~~~~~~~~
nvapi_lite_salstart.h:821:42: error: expected primary-expression before 'return'
#define NVAPI_INTERFACE extern __success(return == NVAPI_OK) NvAPI_Status __cdecl
^
nvapi.h:1159:1: note: in expansion of macro 'NVAPI_INTERFACE'
NVAPI_INTERFACE NvAPI_OGL_ExpertModeSet(NvU32 expertDetailLevel,
^~~~~~~~~~~~~~~
nvapi_lite_salstart.h:821:41: warning: '__success' initialized and declared 'extern'
#define NVAPI_INTERFACE extern __success(return == NVAPI_OK) NvAPI_Status __cdecl
^
nvapi.h:1167:1: note: in expansion of macro 'NVAPI_INTERFACE'
NVAPI_INTERFACE NvAPI_OGL_ExpertModeGet(NvU32 *pExpertDetailLevel,
^~~~~~~~~~~~~~~
nvapi_lite_salstart.h:821:41: error: redefinition of 'int __success'
#define NVAPI_INTERFACE extern __success(return == NVAPI_OK) NvAPI_Status __cdecl
^
nvapi.h:1167:1: note: in expansion of macro 'NVAPI_INTERFACE'
NVAPI_INTERFACE NvAPI_OGL_ExpertModeGet(NvU32 *pExpertDetailLevel,
^~~~~~~~~~~~~~~
nvapi_lite_salstart.h:821:32: note: 'int __success' previously defined here
#define NVAPI_INTERFACE extern __success(return == NVAPI_OK) NvAPI_Status __cdecl
^
nvapi.h:99:1: note: in expansion of macro 'NVAPI_INTERFACE'
NVAPI_INTERFACE NvAPI_Initialize();
^~~~~~~~~~~~~~~
nvapi_lite_salstart.h:821:42: error: expected primary-expression before 'return'
#define NVAPI_INTERFACE extern __success(return == NVAPI_OK) NvAPI_Status __cdecl
^
nvapi.h:1167:1: note: in expansion of macro 'NVAPI_INTERFACE'
NVAPI_INTERFACE NvAPI_OGL_ExpertModeGet(NvU32 *pExpertDetailLevel,
^~~~~~~~~~~~~~~
nvapi_lite_salstart.h:821:41: warning: '__success' initialized and declared 'extern'
#define NVAPI_INTERFACE extern __success(return == NVAPI_OK) NvAPI_Status __cdecl
^
nvapi.h:1209:1: note: in expansion of macro 'NVAPI_INTERFACE'
NVAPI_INTERFACE NvAPI_OGL_ExpertModeDefaultsSet(NvU32 expertDetailLevel,
^~~~~~~~~~~~~~~
nvapi_lite_salstart.h:821:41: error: redefinition of 'int __success'
#define NVAPI_INTERFACE extern __success(return == NVAPI_OK) NvAPI_Status __cdecl
^
nvapi.h:1209:1: note: in expansion of macro 'NVAPI_INTERFACE'
NVAPI_INTERFACE NvAPI_OGL_ExpertModeDefaultsSet(NvU32 expertDetailLevel,
^~~~~~~~~~~~~~~
nvapi_lite_salstart.h:821:32: note: 'int __success' previously defined here
#define NVAPI_INTERFACE extern __success(return == NVAPI_OK) NvAPI_Status __cdecl
^
nvapi.h:99:1: note: in expansion of macro 'NVAPI_INTERFACE'
NVAPI_INTERFACE NvAPI_Initialize();
^~~~~~~~~~~~~~~
nvapi_lite_salstart.h:821:42: error: expected primary-expression before 'return'
#define NVAPI_INTERFACE extern __success(return == NVAPI_OK) NvAPI_Status __cdecl
^
nvapi.h:1209:1: note: in expansion of macro 'NVAPI_INTERFACE'
NVAPI_INTERFACE NvAPI_OGL_ExpertModeDefaultsSet(NvU32 expertDetailLevel,
^~~~~~~~~~~~~~~
nvapi_lite_salstart.h:821:41: warning: '__success' initialized and declared 'extern'
#define NVAPI_INTERFACE extern __success(return == NVAPI_OK) NvAPI_Status __cdecl
^
nvapi.h:1216:1: note: in expansion of macro 'NVAPI_INTERFACE'
NVAPI_INTERFACE NvAPI_OGL_ExpertModeDefaultsGet(NvU32 *pExpertDetailLevel,
^~~~~~~~~~~~~~~
nvapi_lite_salstart.h:821:41: error: redefinition of 'int __success'
#define NVAPI_INTERFACE extern __success(return == NVAPI_OK) NvAPI_Status __cdecl
^
nvapi.h:1216:1: note: in expansion of macro 'NVAPI_INTERFACE'
NVAPI_INTERFACE NvAPI_OGL_ExpertModeDefaultsGet(NvU32 *pExpertDetailLevel,
^~~~~~~~~~~~~~~
nvapi_lite_salstart.h:821:32: note: 'int __success' previously defined here
#define NVAPI_INTERFACE extern __success(return == NVAPI_OK) NvAPI_Status __cdecl
^
nvapi.h:99:1: note: in expansion of macro 'NVAPI_INTERFACE'
NVAPI_INTERFACE NvAPI_Initialize();
^~~~~~~~~~~~~~~
nvapi_lite_salstart.h:821:42: error: expected primary-expression before 'return'
#define NVAPI_INTERFACE extern __success(return == NVAPI_OK) NvAPI_Status __cdecl
^
nvapi.h:1216:1: note: in expansion of macro 'NVAPI_INTERFACE'
NVAPI_INTERFACE NvAPI_OGL_ExpertModeDefaultsGet(NvU32 *pExpertDetailLevel,
^~~~~~~~~~~~~~~
nvapi_lite_salstart.h:821:41: warning: '__success' initialized and declared 'extern'
#define NVAPI_INTERFACE extern __success(return == NVAPI_OK) NvAPI_Status __cdecl
^
nvapi.h:1251:1: note: in expansion of macro 'NVAPI_INTERFACE'
NVAPI_INTERFACE NvAPI_EnumTCCPhysicalGPUs( NvPhysicalGpuHandle nvGPUHandle[NVAPI_MAX_PHYSICAL_GPUS], NvU32 *pGpuCount);
^~~~~~~~~~~~~~~
nvapi_lite_salstart.h:821:41: error: redefinition of 'int __success'
#define NVAPI_INTERFACE extern __success(return == NVAPI_OK) NvAPI_Status __cdecl
^
nvapi.h:1251:1: note: in expansion of macro 'NVAPI_INTERFACE'
NVAPI_INTERFACE NvAPI_EnumTCCPhysicalGPUs( NvPhysicalGpuHandle nvGPUHandle[NVAPI_MAX_PHYSICAL_GPUS], NvU32 *pGpuCount);
^~~~~~~~~~~~~~~
nvapi_lite_salstart.h:821:32: note: 'int __success' previously defined here
#define NVAPI_INTERFACE extern __success(return == NVAPI_OK) NvAPI_Status __cdecl
^
nvapi.h:99:1: note: in expansion of macro 'NVAPI_INTERFACE'
NVAPI_INTERFACE NvAPI_Initialize();
^~~~~~~~~~~~~~~
nvapi_lite_salstart.h:821:42: error: expected primary-expression before 'return'
#define NVAPI_INTERFACE extern __success(return == NVAPI_OK) NvAPI_Status __cdecl
^
nvapi.h:1251:1: note: in expansion of macro 'NVAPI_INTERFACE'
NVAPI_INTERFACE NvAPI_EnumTCCPhysicalGPUs( NvPhysicalGpuHandle nvGPUHandle[NVAPI_MAX_PHYSICAL_GPUS], NvU32 *pGpuCount);
^~~~~~~~~~~~~~~
nvapi_lite_salstart.h:821:41: warning: '__success' initialized and declared 'extern'
#define NVAPI_INTERFACE extern __success(return == NVAPI_OK) NvAPI_Status __cdecl
^
nvapi.h:1282:1: note: in expansion of macro 'NVAPI_INTERFACE'
NVAPI_INTERFACE NvAPI_EnumLogicalGPUs(NvLogicalGpuHandle nvGPUHandle[NVAPI_MAX_LOGICAL_GPUS], NvU32 *pGpuCount);
^~~~~~~~~~~~~~~
nvapi_lite_salstart.h:821:41: error: redefinition of 'int __success'
#define NVAPI_INTERFACE extern __success(return == NVAPI_OK) NvAPI_Status __cdecl
^
nvapi.h:1282:1: note: in expansion of macro 'NVAPI_INTERFACE'
NVAPI_INTERFACE NvAPI_EnumLogicalGPUs(NvLogicalGpuHandle nvGPUHandle[NVAPI_MAX_LOGICAL_GPUS], NvU32 *pGpuCount);
^~~~~~~~~~~~~~~
nvapi_lite_salstart.h:821:32: note: 'int __success' previously defined here
#define NVAPI_INTERFACE extern __success(return == NVAPI_OK) NvAPI_Status __cdecl
^
nvapi.h:99:1: note: in expansion of macro 'NVAPI_INTERFACE'
NVAPI_INTERFACE NvAPI_Initialize();
^~~~~~~~~~~~~~~
nvapi_lite_salstart.h:821:42: error: expected primary-expression before 'return'
#define NVAPI_INTERFACE extern __success(return == NVAPI_OK) NvAPI_Status __cdecl
^
nvapi.h:1282:1: note: in expansion of macro 'NVAPI_INTERFACE'
NVAPI_INTERFACE NvAPI_EnumLogicalGPUs(NvLogicalGpuHandle nvGPUHandle[NVAPI_MAX_LOGICAL_GPUS], NvU32 *pGpuCount);
^~~~~~~~~~~~~~~
nvapi_lite_salstart.h:821:41: warning: '__success' initialized and declared 'extern'
#define NVAPI_INTERFACE extern __success(return == NVAPI_OK) NvAPI_Status __cdecl
^
nvapi.h:1308:1: note: in expansion of macro 'NVAPI_INTERFACE'
NVAPI_INTERFACE NvAPI_GetPhysicalGPUsFromDisplay(NvDisplayHandle hNvDisp, NvPhysicalGpuHandle nvGPUHandle[NVAPI_MAX_PHYSICAL_GPUS], NvU32 *pGpuCount);
^~~~~~~~~~~~~~~
nvapi_lite_salstart.h:821:41: error: redefinition of 'int __success'
#define NVAPI_INTERFACE extern __success(return == NVAPI_OK) NvAPI_Status __cdecl
^
nvapi.h:1308:1: note: in expansion of macro 'NVAPI_INTERFACE'
NVAPI_INTERFACE NvAPI_GetPhysicalGPUsFromDisplay(NvDisplayHandle hNvDisp, NvPhysicalGpuHandle nvGPUHandle[NVAPI_MAX_PHYSICAL_GPUS], NvU32 *pGpuCount);
^~~~~~~~~~~~~~~
nvapi_lite_salstart.h:821:32: note: 'int __success' previously defined here
#define NVAPI_INTERFACE extern __success(return == NVAPI_OK) NvAPI_Status __cdecl
^
...
Я установил Mingw-W64, и я использую g++
версия:
g++ (x86_64-posix-sjlj-rev2, Built by MinGW-W64 project) 6.3.0
Copyright (C) 2016 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
Я скачал NVIDIA NVAPI SDK с https://developer.nvidia.com/gameworksdownload#?search=nvapi
Я нашел ответ Вот что объясняет эти переменные создаются с #define
в файле nvapi_lite_salstart.h
а затем неопределенный с помощью #undef
в файле nvapi_lite_salend.h
который вызывается в начале и в конце соответственно в каждом из файлов заголовка, как указано здесь в начале nvapi.h
:
#include"nvapi_lite_salstart.h" //Remove this line
#include"nvapi_lite_common.h"#include"nvapi_lite_sli.h"#include"nvapi_lite_surround.h"#include"nvapi_lite_stereo.h"#include"nvapi_lite_d3dext.h"#include"nvapi_lite_salstart.h" //Add this line to fix the errors
Как видите, похоже, что файл «salstart» просто нужно переместить в конец списка, потому что по какой-то причине он неверно вверху. Не уверен, почему это работает должным образом в Visual Studio (это происходит без внесения вышеуказанных изменений), но это по крайней мере исправило эти ошибки в MinGW; однако файл скомпилированной библиотеки, предоставленный nVidia (либо nvapi.lib
или же nvapi64.lib
) НЕ совместим с MinGW, поэтому вы вынуждены использовать MS Visual Studio.
Похоже, что файлы заголовков, представленные в API NVIDIA, не совместимы с g++
Компилятор GCC. Поэтому я решил использовать Microsoft C / C ++ x64 компилятор.
я использовал CMake
(v3.5.2) для создания решения Visual Studio 2010, и это работало нормально после того, как я поиграл CMakeLists.txt
файл.
Это содержание моего CMakeLists.txt
:
cmake_minimum_required(VERSION 3.5)
include_directories(3rdparty)
link_directories(3rdparty/amd64)
add_executable(nvapi_test nvapi_hello.cpp)
target_link_libraries(nvapi_test nvapi64.lib)
И 3rdparty
каталог содержит amd64
папка где nvapi64.lib
есть, а также NVAPI *.h
а также *.c
файлы.
Также, как упоминалось в комментариях к моему вопросу (@RichardCritten), мне пришлось добавить #include <Windows.h>
на вершине моего .cpp
файл для его правильной компиляции.