How to include winsock (ws) library in Qt Application
I try to add winsock functionality in non-qt console app created in qt creator.
My code
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
|
#pragma comment(lib,"Ws2_32.lib")
#include <winsock2.h>
#include <iostream>
#define REMOTE_ADDR 37.18.153.219
using namespace std;
int main()
{
int error;
WSADATA ws;
if (FAILED( WSAStartup(MAKEWORD(1, 1), &ws))) {
error = WSAGetLastError();
}
SOCKET s;
if (INVALID_SOCKET == (s = socket (AF_INET, SOCK_STREAM, 0))) {
error = WSAGetLastError();
}
// sockaddr_in s_addr;
// ZeroMemory(&s_addr, sizeof(s_addr));
// s_addr.sin_family = AF_INET;
// s_addr.sin_addr.S_un.S_addr = inet_addr(REMOTE_ADDR);
// s_addr.sin_port = htons(80);
// if (SOCKET_ERROR = (connect(s, (sockaddr*) &s_addr, sizeof(s_addr)))) {
// error = WSAGetLastError();
// }
}
|
How can I fix this compiling error?
:-1: ошибка: LNK1104: не удается открыть файл "ws2_32.obj"
what means this
can not open file ws2_32.obj
My OS is Windows 7 x64, QtC version is 3.2.1.
Thnks for help.
I tried
1 2
|
INCLUDEPATH += "C:\Program Files\Microsoft SDKs\Windows\v6.0A\Lib\x64"
LIBS+="WS2_32.Lib"
|
|
LIBS+="C:\Program Files\Microsoft SDKs\Windows\v6.0A\Lib\x64\WS2_32.Lib"
|
The same error appears.
My bad. I used folder like C:\Users\[another user] in which I have not write permissions. Srry.
Topic archived. No new replies allowed.