Solved

Compile

Posted on 2001-08-21
10
350 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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
add this to your header file:

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

Expert Comment

by:newmang
Comment Utility
I think this question has been answered....any response from the original poster?
0
Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

 

Author Comment

by:ronandersen
Comment Utility
This question was answered
0
 
LVL 4

Expert Comment

by:newmang
Comment Utility
Goodoh! Glad to help

Cheers - Gavin
0
 
LVL 11

Expert Comment

by:vo1d
Comment Utility
:)
0
 
LVL 1

Expert Comment

by:Moondancer
Comment Utility
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
Comment Utility
Force-accepted by
Netminder
CS Moderator
0

Featured Post

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

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…
Video by: Grant
The goal of this video is to provide viewers with basic examples to understand and use for-loops 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.

762 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

9 Experts available now in Live!

Get 1:1 Help Now