Solved

Compile

Posted on 2001-08-21
10
360 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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
 

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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Windows programmers of the C/C++ variety, how many of you realise that since Window 9x Microsoft has been lying to you about what constitutes Unicode (http://en.wikipedia.org/wiki/Unicode)? They will have you believe that Unicode requires you to use…
Examines three attack vectors, specifically, the different types of malware used in malicious attacks, web application attacks, and finally, network based attacks.  Concludes by examining the means of securing and protecting critical systems and inf…
The goal of this video is to provide viewers with basic examples to understand and use pointers in the C programming language.
The goal of this video is to provide viewers with basic examples to understand opening and writing to files in the C programming language.

719 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