| | |
Unknown errors in code (doesn't connect to dns local server)
Please support our C++ advertiser: Intel Parallel Studio Home
![]() |
•
•
Join Date: Nov 2008
Posts: 8
Reputation:
Solved Threads: 0
Hello
I have a problem with this code. I'm trying to connect to local dns server in order to get the ip of the hostname( that user would enter). For now, i'm just trying to connect to the local dns server, and this code gives me following 8 errors..
client.obj : error LNK2001: unresolved external symbol __imp__closesocket@4
client.obj : error LNK2001: unresolved external symbol __imp__connect@12
client.obj : error LNK2001: unresolved external symbol __imp__htons@4
client.obj : error LNK2001: unresolved external symbol __imp__inet_addr@4
client.obj : error LNK2001: unresolved external symbol __imp__socket@12
client.obj : error LNK2001: unresolved external symbol __imp__WSACleanup@0
client.obj : error LNK2001: unresolved external symbol __imp__WSAStartup@8
Debug/client.exe : fatal error LNK1120: 7 unresolved externals
Error executing link.exe.
The code goes here
I don't know what to do... Kindly help me out, I need to submit my assignment by Friday......
Regards
I have a problem with this code. I'm trying to connect to local dns server in order to get the ip of the hostname( that user would enter). For now, i'm just trying to connect to the local dns server, and this code gives me following 8 errors..
client.obj : error LNK2001: unresolved external symbol __imp__closesocket@4
client.obj : error LNK2001: unresolved external symbol __imp__connect@12
client.obj : error LNK2001: unresolved external symbol __imp__htons@4
client.obj : error LNK2001: unresolved external symbol __imp__inet_addr@4
client.obj : error LNK2001: unresolved external symbol __imp__socket@12
client.obj : error LNK2001: unresolved external symbol __imp__WSACleanup@0
client.obj : error LNK2001: unresolved external symbol __imp__WSAStartup@8
Debug/client.exe : fatal error LNK1120: 7 unresolved externals
Error executing link.exe.
The code goes here
C++ Syntax (Toggle Plain Text)
#define WIN32_LEAN_AND_MEAN #pragma comment(lib, "wininet.lib") #include <winsock2.h> #include <windows.h> #include <iostream.h> #include <conio.h> #include <string> using namespace std; void main() { WSADATA wsadat; WORD rVersion; rVersion = MAKEWORD(2,0); if(WSAStartup(rVersion, &wsadat) != NO_ERROR) { cout<<"WSA initialization failed.\n"; WSACleanup(); return; } SOCKET client; client = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP); if(client == INVALID_SOCKET) { cout<<"Error creating socket.\n"; WSACleanup(); return; } char *ip= "208.67.222.222"; cout<<ip; SOCKADDR_IN server; server.sin_family= AF_INET; server.sin_addr.s_addr= inet_addr(ip); server.sin_port= htons(53); if(connect(client, (SOCKADDR*) &server, sizeof(server)) == SOCKET_ERROR) { cout<<"Connection cannot be established. \n"; WSACleanup(); return; } closesocket(client); WSACleanup(); return; }
Regards
“Measuring programming progress by lines of code is like measuring aircraft building progress by weight.” (Bill Gates)
•
•
Join Date: Nov 2008
Posts: 8
Reputation:
Solved Threads: 0
0
#3 Oct 21st, 2009
•
•
•
•
You're not linking to the correct library. I'm not 100% sure, but adding:
#pragma comment(lib, "wsock32.lib")should do the trick
Loaded 'ntdll.dll', no matching symbolic information found.
Loaded 'C:\WINDOWS\system32\kernel32.dll', no matching symbolic information found.
Loaded 'C:\WINDOWS\system32\wsock32.dll', no matching symbolic information found.
Loaded 'C:\WINDOWS\system32\ws2_32.dll', no matching symbolic information found.
Loaded 'C:\WINDOWS\system32\msvcrt.dll', no matching symbolic information found.
Loaded 'C:\WINDOWS\system32\ws2help.dll', no matching symbolic information found.
Loaded 'C:\WINDOWS\system32\advapi32.dll', no matching symbolic information found.
Loaded 'C:\WINDOWS\system32\rpcrt4.dll', no matching symbolic information found.
Loaded 'C:\WINDOWS\system32\shimeng.dll', no matching symbolic information found.
Loaded 'C:\WINDOWS\system32\mswsock.dll', no matching symbolic information found.
Loaded 'C:\WINDOWS\system32\hnetcfg.dll', no matching symbolic information found.
Loaded 'C:\WINDOWS\system32\gdi32.dll', no matching symbolic information found.
Loaded 'C:\WINDOWS\system32\user32.dll', no matching symbolic information found.
Loaded 'C:\WINDOWS\system32\imm32.dll', no matching symbolic information found.
Loaded 'C:\WINDOWS\system32\lpk.dll', no matching symbolic information found.
Loaded 'C:\WINDOWS\system32\usp10.dll', no matching symbolic information found.
Loaded 'C:\WINDOWS\system32\wshtcpip.dll', no matching symbolic information found.
The thread 0x850 has exited with code 0 (0x0).
The program 'C:\Documents and Settings\Yasir\Desktop\Debug\client.exe' has exited with code 0 (0x0)
Now what??
Last edited by Umar Ali; Oct 21st, 2009 at 6:26 am.
“Measuring programming progress by lines of code is like measuring aircraft building progress by weight.” (Bill Gates)
![]() |
Similar Threads
- local server with asp.net website (ASP.NET)
- Using VB Code - Silent download pdf from server and print to local printer (Visual Basic 4 / 5 / 6)
- File.Delete('imagepath'); works fine on local server but not on live server (C#)
- Cannot find server or DNS Error - please help! (Viruses, Spyware and other Nasties)
- How to connect in sql "server"? (Visual Basic 4 / 5 / 6)
- which php local server is good. (PHP)
- Sql Server Database Connector (JSP)
- Problem starting windows xp.. (Windows NT / 2000 / XP)
Other Threads in the C++ Forum
- Previous Thread: Display result in form view when use console application
- Next Thread: multiple definition???
Views: 336 | Replies: 6
| Thread Tools | Search this Thread |
Tag cloud for C++
6 api application array arrays based beginner binary bmp c++ c/c++ calculator char char* class classes code compile compiler console conversion convert count data delete deploy dll download dynamiccharacterarray encryption error file format forms fstream function functions game givemetehcodez graph homeworkhelp iamthwee ifstream input int java lib library lines list loop looping loops map math matrix memory newbie news number numbertoword output pointer problem program programming project python random read recursion recursive reference return rpg search simple sort sorting spoonfeeding string strings struct temperature template templates text tree url variable vector video visual visualstudio void win32 windows winsock wordfrequency wxwidgets






