IonicWind Software

IWBasic => General Questions => Topic started by: King64 on January 22, 2017, 04:13:42 AM

Title: nvapi.lib error
Post by: King64 on January 22, 2017, 04:13:42 AM
Hi guys, i'm working around my Gigabyte GeForce 210, and i'd like to be able to access NVidia APIs. I wrote a very basic program to load and load nvapi.dll, using nvapi.lib that comes with NVidia SDK, but the EBasic compiler reports following errors:

Unresolved external NvAPI_Initialize
Error: Unresolved extern NvAPI_Initialize
Error: Unresolved extern NvAPI_Unload

and that's is the code:

$USE "nvapi.lib"

DECLARE EXTERN NvAPI_Initialize(),INT
DECLARE EXTERN NvAPI_Unload(),INT

OPENCONSOLE

IF NvAPI_Initialize() <> 0
PRINT "Unable to Initialize NVAPI."
ELSE
PRINT "Library OK"
NvAPI_Unload()
DO:UNTIL INKEY$<>""
ENDIF
END


Any suggestion?  ??? Thanks in advance  :)
Title: Re: nvapi.lib error
Post by: Andy on January 22, 2017, 05:00:43 AM
You need to make sure the nvapi.lib file is in your C:\IWBDev3\libs folder.

Alternatively, compile the source code in the same folder as the nvapi lib file.

Try that.

Andy.
:)
Title: Re: nvapi.lib error
Post by: King64 on January 22, 2017, 10:30:31 AM
Hi Andy, the nvapi.lib is present in the libs dir. The NVAPI documentation says:
Quote
NvAPI cannot be dynamically linked to applications. You must create a static link to the library and then call NvAPI_Initialize(), which loads nvapi.dll dynamically...
So i write a small wrapper like a static .lib file, adding nvapi.lib into the project

$USE "nvapi.lib"

DECLARE CDECL EXTERN NvAPI_Initialize(),INT
DECLARE CDECL EXTERN NvAPI_Unload(),INT

GLOBAL __NvAPI_Initialize
GLOBAL __NvAPI_Unload

SUB __NvAPI_Initialize(),INT

RETURN NvAPI_Initialize()

ENDSUB


SUB __NvAPI_Unload(),INT

RETURN NvAPI_Unload()

ENDSUB

and using it

$USE "nVGPU.lib" ' my wrapper

DECLARE EXTERN __NvAPI_Initialize(),INT
DECLARE EXTERN __NvAPI_Unload(),INT

OPENCONSOLE

IF __NvAPI_Initialize() <> 0
PRINT "Unable to Initialize NVAPI."
ELSE
PRINT "Library OK"
__NvAPI_Unload()
ENDIF
DO:UNTIL INKEY$<>""
END

but it returns the same error
??? ??? ???