?
Solved

Network Programming

Posted on 1998-12-08
11
Medium Priority
?
210 Views
Last Modified: 2010-04-15
I m writing a TCP/IP network program using C on MS Visual C++ 5.0 on a WinNT platform . I get LNK2001 error whenever i link my files ... any ideas ?
0
Comment
Question by:SkyWolf
[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
  • 5
  • 5
11 Comments
 
LVL 6

Accepted Solution

by:
stsanz earned 300 total points
ID: 1254945
If you use TCP/IP functions, you have to declare winsock library in your Visual C++ project.
Go to menu Project/Settings..., click on "link" tab and add wsock32.lib and ws2_32.lib in "Object/Library modules" edit box.

Your program should now link correctly.
Otherwise, tell us what is the full LNK2001 error message.


0
 
LVL 1

Expert Comment

by:billyh
ID: 1254946
I usually get that error when I have defined a method in one of my classes and then forgetting to implement it in my defination file. Other causes of this error are using the wrong case when implementing a method, remember C is case-sensitive.
0
 

Author Comment

by:SkyWolf
ID: 1254947
Now that u added both lib to the Object/Library i got these errors ....

LIBCD.lib(wincrt0.obj) : error LNK2001: unresolved external symbol _WinMain@16
Debug/alarmman.exe : fatal error LNK1120: 1 unresolved externals

0
Industry Leaders: 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!

 

Author Comment

by:SkyWolf
ID: 1254948
sorry ...typo...i mean now that i added the lib into Object/Library ...
0
 
LVL 6

Expert Comment

by:stsanz
ID: 1254949
Is your program a console program (with a main() function) or a windows program (with a WinMain() function)

Do you have a main or WinMain function ?
Does the same link error message appear if you compile to Release configuration, instead of Debug ?


0
 

Author Comment

by:SkyWolf
ID: 1254950
I am using a main() ... I still get the error if the output file is to Release .....
0
 
LVL 6

Expert Comment

by:stsanz
ID: 1254951
If you want to create a windows program you have to replace your main() function by the WinMain() function :

int APIENTRY WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
  {
  // Do the startup stuff

  return 0 ;
  }

Instead, if you want to create an old-fashioned "DOS" program and use main() function, you have to select "Win32 Console Application" when you create a new project in Visual C++

0
 

Author Comment

by:SkyWolf
ID: 1254952
erm...i hav a qs though , is it that , if i use socket tp pass data, i am ACTUALLY not implementing TCP/IP ?
0
 
LVL 6

Expert Comment

by:stsanz
ID: 1254953
Sorry I can't understand your question. Do you mean you want to know if your program implements a TCP/IP protocol when it uses socket layers functions ? Can you please ask your question again ?



0
 

Author Comment

by:SkyWolf
ID: 1254954
"whack" me if I am wrong here *smile* ..TCP/IP is a connectionless protocol which  doesnt use the bind() functional call ? so the standard procedures of creating a socket(),recv(),send() is as usual ?
0
 
LVL 6

Expert Comment

by:stsanz
ID: 1254955
I don't know how to use socket functions. You should create a new question on "C language" home page about it.

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

Have you thought about creating an iPhone application (app), but didn't even know where to get started? Here's how: ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ Important pre-programming comments: I’ve never tri…
Summary: This tutorial covers some basics of pointer, pointer arithmetic and function pointer. What is a pointer: A pointer is a variable which holds an address. This address might be address of another variable/address of devices/address of fu…
Video by: Grant
The goal of this video is to provide viewers with basic examples to understand and use while-loops in the C programming language.
The goal of this video is to provide viewers with basic examples to understand how to create, access, and change arrays in the C programming language.
Suggested Courses

752 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