Solved

Compile

Posted on 2001-08-21
10
353 Views
Last Modified: 2010-04-15
My programs compile, but when I try to create the exe, I receive the following errors:

Linking...
t6.obj : error LNK2001: unresolved external symbol _htons@4
t6.obj : error LNK2001: unresolved external symbol _inet_ntoa@4
t6.obj : error LNK2001: unresolved external symbol _gethostbyname@4
t6.obj : error LNK2001: unresolved external symbol _inet_addr@4
t6.obj : error LNK2001: unresolved external symbol _connect@12
t6.obj : error LNK2001: unresolved external symbol _socket@12
t6.obj : error LNK2001: unresolved external symbol _send@16
t6.obj : error LNK2001: unresolved external symbol _recv@16
ws-util.obj : error LNK2001: unresolved external symbol _recv@16
ws-util.obj : error LNK2001: unresolved external symbol _WSAGetLastError@0
ws-util.obj : error LNK2001: unresolved external symbol _closesocket@4
ws-util.obj : error LNK2001: unresolved external symbol _shutdown@8
LIBCD.lib(crt0.obj) : error LNK2001: unresolved external symbol _main
Debug/t6.exe : fatal error LNK1120: 12 unresolved externals
Error executing link.exe.

t6.exe - 14 error(s), 0 warning(s)


WHat am I missing?
0
Comment
Question by:ronandersen
10 Comments
 
LVL 4

Accepted Solution

by:
newmang earned 50 total points
ID: 6411763
Assuming that you are using a Windows compiler (VC??) then you need to include the library ws2_32.lib.

If you are using a different platform let me know.

Cheers - Gavin
0
 
LVL 1

Expert Comment

by:Aggarwal
ID: 6415944
surely u r working on windows !!!

as we dun need "WSAGetLastError"  on unix !!!including the above said lib will help you !!!

0
 
LVL 2

Expert Comment

by:abesoft
ID: 6427422
The two previous answers were right.  You need to link ws2_32.lib with your exe.

The way to track down an error like this is to find the name of the missing function (by un-mangling it, so if you get an error for _htons@4, then the actual function is htons) and look up the help for that function.  The MSDN/VC++ help will list at the bottom of the page something like this:
  Version: Requires Windows Sockets 1.1 or later.
  Header: Declared in Winsock2.h.
  Library: Use Ws2_32.lib.

and that will tell you which library you need to link.

Hope this helps.
0
 
LVL 11

Expert Comment

by:vo1d
ID: 6437420
add this to your header file:

#include <winsock2.h>
#pragma library( "WS2_32.LIB" )
0
 
LVL 4

Expert Comment

by:newmang
ID: 6438883
I think this question has been answered....any response from the original poster?
0
Swamped with email signature updates?

Have you been given a load of changes to make to your users’ email signatures? Having to manually implement multiple signatures for every department? Let Exclaimer save you from being swamped with email signature updates!

 

Author Comment

by:ronandersen
ID: 6439352
This question was answered
0
 
LVL 4

Expert Comment

by:newmang
ID: 6439594
Goodoh! Glad to help

Cheers - Gavin
0
 
LVL 11

Expert Comment

by:vo1d
ID: 6440428
:)
0
 
LVL 1

Expert Comment

by:Moondancer
ID: 6858910
ADMINISTRATION WILL BE CONTACTING YOU REGARDING YOUR ACCOUNT SHORTLY.

Question(s) below appears to have been abandoned. Your options are:
 
1. Accept a Comment As Answer (use the button next to the Expert's name).
2. Close the question if the information was not useful to you. You must tell the participants why you wish to do this, and allow for Expert response.
3. Ask Community Support to help split points between participating experts, or just comment here with details and we'll respond with the process.
4. Delete the question. Again, please comment to advise the other participants why you wish to do this.

For special handling needs, please post a zero point question in the link below and include the question QID/link(s) that it regards.
http://www.experts-exchange.com/jsp/qList.jsp?ta=commspt
 
Please click the Help Desk link on the left for Member Guidelines, Member Agreement and the Question/Answer process.  http://www.experts-exchange.com/jsp/cmtyHelpDesk.jsp

Please click you Member Profile to view your question history and keep them all current with updates as the collaboration effort continues, to track all your open and locked questions at this site.  If you are an EE Pro user, use the Power Search option to find them.

To view your open questions, please click the following link(s) and keep them all current with updates.
http://www.experts-exchange.com/questions/Q.11791338.html
http://www.experts-exchange.com/questions/Q.20117180.html
http://www.experts-exchange.com/questions/Q.20149452.html
http://www.experts-exchange.com/questions/Q.20149453.html
http://www.experts-exchange.com/questions/Q.20171942.html
http://www.experts-exchange.com/questions/Q.20264541.html
http://www.experts-exchange.com/questions/Q.20264895.html
http://www.experts-exchange.com/questions/Q.20265085.html




PLEASE DO NOT AWARD THE POINTS TO ME.  
 
------------>  EXPERTS:  Please leave any comments regarding your closing recommendations if this item remains inactive another seven (7) days.  Also, if you are interested in the cleanup effort, please click this link http://www.experts-exchange.com/jsp/qManageQuestion.jsp?ta=commspt&qid=20274643
 
Thank you everyone.
 
Moondancer
Moderator @ Experts Exchange

P.S.  For any year 2000 questions, special attention is needed to ensure the first correct response is awarded, since they are not in the comment date order, but rather in Member ID order.
0
 
LVL 5

Expert Comment

by:Netminder
ID: 6957230
Force-accepted by
Netminder
CS Moderator
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Summary: This tutorial covers some basics of pointer, pointer arithmetic and function pointer. What is a pointer: A pointer is a variable which holds an address. This address might be address of another variable/address of devices/address of fu…
This is a short and sweet, but (hopefully) to the point article. There seems to be some fundamental misunderstanding about the function prototype for the "main" function in C and C++, more specifically what type this function should return. I see so…
The goal of this video is to provide viewers with basic examples to understand how to use strings and some functions related to them in the C programming language.
Video by: Grant
The goal of this video is to provide viewers with basic examples to understand and use while-loops in the C programming language.

863 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now