GIDForums  

Go Back   GIDForums > Computer Programming Forums > MS Visual C++ / MFC Forum
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

 
 
Thread Tools Search this Thread Rate Thread
  #1  
Old 20-May-2006, 04:53
vkiran_v vkiran_v is offline
New Member
 
Join Date: May 2006
Posts: 14
vkiran_v is on a distinguished road
Arrow

Resolving "error LNK2001"


I am working on VC++ and when I compile my socket programming it's giving no compile errors but when I build I am getting some error like:

Code:
Deleting intermediate files and output files for project 'saitestbed1 - Win32 Release'. Deleting intermediate files and output files for project 'saitestbed1 - Win32 Debug'. --------------------Configuration: saitestbed1 - Win32 Release-------------------- Compiling... saitestbed1.cpp Linking... saitestbed1.obj : error LNK2001: unresolved external symbol _WSACleanup@0 saitestbed1.obj : error LNK2001: unresolved external symbol _WSAStartup@8 saitestbed1.obj : error LNK2001: unresolved external symbol _recv@16 saitestbed1.obj : error LNK2001: unresolved external symbol _accept@12 saitestbed1.obj : error LNK2001: unresolved external symbol _listen@8 saitestbed1.obj : error LNK2001: unresolved external symbol _bind@12 saitestbed1.obj : error LNK2001: unresolved external symbol _inet_ntoa@4 saitestbed1.obj : error LNK2001: unresolved external symbol _htons@4 saitestbed1.obj : error LNK2001: unresolved external symbol _gethostbyname@4 saitestbed1.obj : error LNK2001: unresolved external symbol _gethostname@8 saitestbed1.obj : error LNK2001: unresolved external symbol _closesocket@4 saitestbed1.obj : error LNK2001: unresolved external symbol _socket@12 saitestbed1.obj : error LNK2001: unresolved external symbol _send@16 saitestbed1.obj : error LNK2001: unresolved external symbol _connect@12 saitestbed1.obj : error LNK2001: unresolved external symbol _inet_addr@4 saitestbed1.obj : error LNK2001: unresolved external symbol _setsockopt@20 saitestbed1.obj : error LNK2001: unresolved external symbol _getsockopt@20 nafxcw.lib(thrdcore.obj) : error LNK2001: unresolved external symbol __endthreadex nafxcw.lib(thrdcore.obj) : error LNK2001: unresolved external symbol __beginthreadex Release/saitestbed1.exe : fatal error LNK1120: 19 unresolved externals Error executing link.exe. saitestbed1.exe - 20 error(s), 0 warning(s) --------------------Configuration: saitestbed1 - Win32 Debug-------------------- Compiling... saitestbed1.cpp Linking... saitestbed1.obj : error LNK2001: unresolved external symbol _WSACleanup@0 saitestbed1.obj : error LNK2001: unresolved external symbol _WSAStartup@8 saitestbed1.obj : error LNK2001: unresolved external symbol _recv@16 saitestbed1.obj : error LNK2001: unresolved external symbol _accept@12 saitestbed1.obj : error LNK2001: unresolved external symbol _listen@8 saitestbed1.obj : error LNK2001: unresolved external symbol _bind@12 saitestbed1.obj : error LNK2001: unresolved external symbol _inet_ntoa@4 saitestbed1.obj : error LNK2001: unresolved external symbol _htons@4 saitestbed1.obj : error LNK2001: unresolved external symbol _gethostbyname@4 saitestbed1.obj : error LNK2001: unresolved external symbol _gethostname@8 saitestbed1.obj : error LNK2001: unresolved external symbol _closesocket@4 saitestbed1.obj : error LNK2001: unresolved external symbol _socket@12 saitestbed1.obj : error LNK2001: unresolved external symbol _send@16 saitestbed1.obj : error LNK2001: unresolved external symbol _connect@12 saitestbed1.obj : error LNK2001: unresolved external symbol _inet_addr@4 saitestbed1.obj : error LNK2001: unresolved external symbol _setsockopt@20 saitestbed1.obj : error LNK2001: unresolved external symbol _getsockopt@20 nafxcwd.lib(thrdcore.obj) : error LNK2001: unresolved external symbol __endthreadex nafxcwd.lib(thrdcore.obj) : error LNK2001: unresolved external symbol __beginthreadex Debug/saitestbed1.exe : fatal error LNK1120: 19 unresolved externals Error executing link.exe. saitestbed1.exe - 20 error(s), 0 warning(s)

Help me in resolving these error please.
  #2  
Old 20-May-2006, 13:59
davekw7x davekw7x is offline
Outstanding Member
 
Join Date: Feb 2004
Location: Left Coast, USA
Posts: 4,703
davekw7x is a splendid one to beholddavekw7x is a splendid one to beholddavekw7x is a splendid one to beholddavekw7x is a splendid one to beholddavekw7x is a splendid one to beholddavekw7x is a splendid one to beholddavekw7x is a splendid one to behold

Re: pl.. help me resolving "error LNK2001"


Errors 1-17: Depending on what compiler version you are using, add wsock32.lib to your project or, maybe, ws2_32.lib: http://msdn.microsoft.com/library/de...astartup_2.asp

Errors 18-19: Compile with multi-threaded versions of the run-time libraries. Depending on what compiler version you are using, this may require a "/MT" compiler switch: http://msdn2.microsoft.com/en-us/lib...cb(VS.80).aspx

Regards,

Dave
  #3  
Old 10-Jul-2007, 17:13
ArleneM ArleneM is offline
New Member
 
Join Date: Jul 2007
Posts: 8
ArleneM is on a distinguished road

Re: pl.. help me resolving "error LNK2001"


Dave (or anyone),

I made the adjustment that was given for errors 1 - 17, and that cleared my compiler error. However, I get the following errors when I run the program:

Code:
Gradebook.obj : error LNK2001: unresolved external symbol "public: void __thiscall GradeBook::setCourseName(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >)" (?setCourseName@GradeBook@@QAEXV?$basic_string@DU?$ char_traits@D@std@@V?$allocator@D@2@@std@@@Z) Gradebook.obj : error LNK2001: unresolved external symbol "public: class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > __thiscall GradeBook::getCourseName(void)" (?getCourseName@GradeBook@@QAE?AV?$basic_string@DU? $char_traits@D@std@@V?$allocator@D@2@@std@@XZ) Gradebook.obj : error LNK2001: unresolved external symbol "public: __thiscall GradeBook::GradeBook(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >)" (??0GradeBook@@QAE@V?$basic_string@DU?$char_traits@D@std@@V? $allocator@D@2@@std@@@Z) Debug/Gradebook.exe : fatal error LNK1120: 3 unresolved externals Error executing link.exe.

Can you help?
  #4  
Old 11-Jul-2007, 08:04
davekw7x davekw7x is offline
Outstanding Member
 
Join Date: Feb 2004
Location: Left Coast, USA
Posts: 4,703
davekw7x is a splendid one to beholddavekw7x is a splendid one to beholddavekw7x is a splendid one to beholddavekw7x is a splendid one to beholddavekw7x is a splendid one to beholddavekw7x is a splendid one to beholddavekw7x is a splendid one to behold

Re: pl.. help me resolving "error LNK2001"


Quote:
Originally Posted by ArleneM

Debug/Gradebook.exe : fatal error LNK1120: 3 unresolved externals
How many cpp files are in your project? How are they linked together? The messages mean that the linker can't find any place where you have compiled three GradeBook class member functions:

setCourseName(string parameter)
setCourseName(void)
GradeBook(string parameter) --- the constructor that has a string argument

Apparently you have declared them (in a header file, perhaps). And you have used them. Maybe in a main() function or other function that was compiled as part of your project. It just can't find where you have compiled them.

Regards,

Dave
  #5  
Old 11-Jul-2007, 09:19
ArleneM ArleneM is offline
New Member
 
Join Date: Jul 2007
Posts: 8
ArleneM is on a distinguished road

Re: pl.. help me resolving "error LNK2001"


Quote:
Originally Posted by davekw7x
How many cpp files are in your project? How are they linked together? The messages mean that the linker can't find any place where you have compiled three GradeBook class member functions:

setCourseName(string parameter)
setCourseName(void)
GradeBook(string parameter) --- the constructor that has a string argument

I believe there are two...Gradebook.cpp and StdAfx.cpp. I don't know how they are linked...I don't know enough about C++. I also have two header files...same names except with a .h.

Quote:
Apparently you have declared them (in a header file, perhaps). And you have used them. Maybe in a main() function or other function that was compiled as part of your project. It just can't find where you have compiled them.

I don't have the project in front of me right now...how would I find where I compiled them?

Thanx for getting back to me so quickly...maybe you will be available tonight and/or tomorrow to answer more questions for me?

Thank you!
Arlene
Last edited by admin : 11-Jul-2007 at 09:24. Reason: Fixed quotes
  #6  
Old 11-Jul-2007, 09:21
ArleneM ArleneM is offline
New Member
 
Join Date: Jul 2007
Posts: 8
ArleneM is on a distinguished road

Re: pl.. help me resolving "error LNK2001"


One more thing...what about those "unresolved external symbol" errors?
  #7  
Old 11-Jul-2007, 10:41
TurboPT's Avatar
TurboPT TurboPT is offline
Regular Member
 
Join Date: Feb 2006
Location: Atlanta, GA
Posts: 958
TurboPT is a jewel in the roughTurboPT is a jewel in the roughTurboPT is a jewel in the rough

Re: Resolving "error LNK2001"


To post #6: Dave answered that in post #4...

It sounds like, based on the error, the GradeBook.cpp file is missing (near the top of the file):
CPP / C++ / C Code:
#include GradeBook.h 
__________________
Use the force...read the source!!
WYCIWYG -- what you code is what you get!
 
 

Recent GIDBlogHalfway done! by crystalattice

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The

All times are GMT -6. The time now is 05:42.


vBulletin, Copyright © 2000 - 2008, Jelsoft Enterprises Ltd.