getcursorpos error

Hi, does anyone know what this error means?

Error LNK2028 unresolved token (0A0001F4) "extern "C" int __stdcall GetCursorPos(struct tagPOINT *)" (?GetCursorPos@@$$J14YGHPAUtagPOINT@@@Z) referenced in function "public: struct tagPOINT __thiscall mouse::get_pos(void)" (?get_pos@mouse@@$$FQAE?AUtagPOINT@@XZ)
It means that your linker can't find a definition for that function.

Presumably, that means you're not linking agains the library (or object code) that contains the definition.
I do not know what to add. Because getcursorpos is in the windows.h library.
Is this a C++\CLI project?

Anyway I googled your error and it came back with this
https://stackoverflow.com/questions/14188931/cursor-position-getcursorpos-in-c-returns-linking-error

Click that and read the first comment posted under the question.
If it helps, a C++/CLI project with just #include <windows.h> int main() {POINT p; GetCursorPos(&p);} gives me linker errors, but adding #pragma comment(lib, "user32.lib") below the include links it all properly. I reckon you didn't add the library to the project properly.

And if that doesn't work, then see:
https://stackoverflow.com/questions/739952/c-cli-linker-gives-unresolved-token-for-win32-function
Check if Gdi32.lib is there in the linker commandline(Properties > Linker > CommandLine).

or
You should link your dll with Gdi32.lib.

You can either do it with a #pragma comment(lib, "gdi32.lib") or in your project's settings under Linker.


Let us know if any of that helped.
Last edited on
I do not know what to add. Because getcursorpos is in the windows.h library.

windows.h
isn't a library, it's a header file. You should learn the difference, because you're going to have a tough time understanding compiler and linker errors without understanding that.

There is loads of documentation for the standard MS/Windows libraries, so it should be easy to find out where that function is defined; indeed, it looks like other posters in this thread have already been able to find that information for you.
Topic archived. No new replies allowed.