Hello guys,
I would like to use the Mavlink protocol inside of my QT GUI.
I defined #include "winsock2.h" to use the SOCKET structure. But I am getting error that socketconnectio is already defined.


Qt Code:
  1. int bytes_sent;
  2. #define DEFAULT_PORT 14550
  3. char target_ip[100];
  4.  
  5. SOCKET ConnectSocket;
  6. int iResult;
  7. typedef int socklen_t;
  8.  
  9.  
  10. void socketconnection()
  11. {
  12. strcpy(target_ip, "127.0.0.1");
  13.  
  14. //----------------------
  15. // Declare and initialize variables.
  16. int iResult;
  17. WSADATA wsaData;
  18.  
  19. ConnectSocket = INVALID_SOCKET;
  20. struct sockaddr_in clientService;
  21. // Initialize Winsock
  22. iResult = WSAStartup(MAKEWORD(2,2), &wsaData);
  23. if (iResult != NO_ERROR) {
  24. cout<<"WSAStartup failed with error: "<< iResult<<endl;
  25. }
  26. ….
To copy to clipboard, switch view to plain text mode 
etc


error LNK2005: "int bytes_sent" (?bytes_sent@@3HA) is already defined in main.obj definiert.
error LNK2005: "unsigned int ConnectSocket" (?ConnectSocket@@3IA) is already defined in main.obj definiert.
error LNK2005: "int iResult" (?iResult@@3HA) is already defined in main.obj definiert.
error LNK2005: "char * target_ip" (?target_ip@@3PADA) is already defined in main.obj definiert.
error LNK2005: "void __cdecl socketconnection(void)" (?socketconnection@@YAXXZ) is already defined in main.obj definiert.
error LNK2005: "void __cdecl closesocket(void)" (?closesocket@@YAXXZ) is already defined in main.obj definiert.
error LNK2005: "void __cdecl mavlinksend(void)" (?mavlinksend@@YAXXZ)is already defined in main.obj definiert.