Solved

Compile

Posted on 2001-08-21
10
356 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
Is Your AD Toolbox Looking More Like a Toybox?

Managing Active Directory can get complicated.  Often, the native tools for managing AD are just not up to the task.  The largest Active Directory installations in the world have relied on one tool to manage their day-to-day administration tasks: Hyena. Start your trial today.

 
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

Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

Question has a verified solution.

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

An Outlet in Cocoa is a persistent reference to a GUI control; it connects a property (a variable) to a control.  For example, it is common to create an Outlet for the text field GUI control and change the text that appears in this field via that Ou…
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…
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.
The goal of this video is to provide viewers with basic examples to understand and use conditional statements in the C programming language.

770 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