mingw-w64 / mingw-w64.github.io

mingw-w64.net web page contents (The new web page)
Other
572 stars 1.16k forks source link

Help my mingW64 has a handicap or my code (help) #22

Open cool1coder opened 1 year ago

cool1coder commented 1 year ago

So this is my code (i am trying to make a little joke virus for my friend)

include

include

include

void invertscreen() { int x, y; x = GetSystemMetrics(SM_CXSCREEN); y = GetSystemMetrics(SM_CXSCREEN); while (0 == 0) { int randx, randy; randx = rand() % x + 0; randy = rand() % x + 0; BitBlt(GetDC(NULL),rand() % x + 0, rand() % y + 0, randx + 200,randy+200,GetDC(NULL),randx,randy,NOTSRCCOPY); } }

int main() { invertscreen(); }

now once compiling i get this error: c:/mingw/bin/../lib/gcc/x86_64-w64-mingw32/11.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:\Users\mverb\AppData\Local\Temp\cchWKwR9.o:main.cpp:(.text+0xc2): undefined reference to `__imp_BitBlt' collect2.exe: error: ld returned 1 exit status

if you know please help before i get a handicap :D

Biswa96 commented 1 year ago

You have to link it properly. Add -lgdi32 linker option while compiling. See https://learn.microsoft.com/en-us/windows/win32/api/wingdi/nf-wingdi-bitblt