It took a function that takes a screenshot in the program and saves it to a file. I found several such functions, but each (!) Of them, when added to the program, causes it to produce such an error when compiling:
C:\{папка_с_файлом.cpp}\collect2.exe [Error] ld returned 1 exit status
And there are no other mistakes, or I correct them. Usually such an error occurs when my code is already compiled and running .exe, and I try to compile and run it again. But, of course, I tried everything, even ran the code on another computer (but also in Dev) - the same error.
If you remove this function, the code works fine again. Tell me what to do?
Here is the current code with one of the options for a function that takes a screenshot:
#include <Winsock2.h>//Ws2_32.lib #include <ws2tcpip.h> #include <Windows.h> #include <iostream> #include <stdio.h> #include <stdlib.h> #include <conio.h> //getch #include <string.h> #include <fcntl.h> #include <unistd.h> #include <sys/types.h> #include <sys/time.h> //#include <sys/socket.h> #define ever (;;) #include <gdiplus.h> #pragma comment(lib, "GdiPlus.lib") //Тут всякий другой код. Вообще, программа для работы с сетью (это клиент). //Но она даже не запускается, выдаёт ту ошибку. using namespace std; using namespace Gdiplus; static const GUID png = { 0x557cf406, 0x1a04, 0x11d3, { 0x9a, 0x73, 0x00, 0x00, 0xf8, 0x1e, 0xf3, 0x2e } }; int PrtScr() { GdiplusStartupInput gdiplusStartupInput; ULONG_PTR gdiplusToken; GdiplusStartup(&gdiplusToken, &gdiplusStartupInput, NULL); HDC scrdc, memdc; HBITMAP membit; scrdc = GetDC(0); int Height, Width; Height = GetSystemMetrics(SM_CYSCREEN); Width = GetSystemMetrics(SM_CXSCREEN); memdc = CreateCompatibleDC(scrdc); membit = CreateCompatibleBitmap(scrdc, Width, Height); SelectObject(memdc, membit); BitBlt(memdc, 0, 0, Width, Height, scrdc, 0, 0, SRCCOPY); HBITMAP hBitmap; hBitmap =(HBITMAP) SelectObject(memdc, membit); Gdiplus::Bitmap bitmap(hBitmap, NULL); char PerMin[12]; strcpy (PerMin,"screen.png" ); bitmap.Save((WCHAR*)PerMin, &png,NULL); DeleteObject(hBitmap); return 0; } ///////////////////////////////////////////////////// int main() { printf ("OK1\n"); getch(); PrtScr(); printf ("OK2\n"); getch(); //Тут всякий иной код return 0; }
#include <Winsock2.h>: Well, you have#include <Winsock2.h>, which means that maybe functions are used from there somewhere. - VladD