• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 375
  • Last Modified:

Compile

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
ronandersen
Asked:
ronandersen
1 Solution
 
newmangCommented:
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
 
AggarwalCommented:
surely u r working on windows !!!

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

0
 
abesoftCommented:
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
Network Scalability - Handle Complex Environments

Monitor your entire network from a single platform. Free 30 Day Trial Now!

 
vo1dCommented:
add this to your header file:

#include <winsock2.h>
#pragma library( "WS2_32.LIB" )
0
 
newmangCommented:
I think this question has been answered....any response from the original poster?
0
 
ronandersenAuthor Commented:
This question was answered
0
 
newmangCommented:
Goodoh! Glad to help

Cheers - Gavin
0
 
vo1dCommented:
:)
0
 
MoondancerCommented:
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
 
NetminderCommented:
Force-accepted by
Netminder
CS Moderator
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Firewall Management 201 with Professor Wool

In this whiteboard video, Professor Wool highlights the challenges, benefits and trade-offs of utilizing zero-touch automation for security policy change management. Watch and Learn!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now