Solved

how to compile winsock program ?

Posted on 1998-03-29
10
372 Views
Last Modified: 2009-12-16
I'm from a UNIX environment programmer and i faced a problem of compiling a socket program (it work on UNIX).
Currently i'm using borland C++4.5 and i'm trying to write a windows base socket program.

just some need info, is that enough just only include thw winsock.h header file ? or what else do i need ? any .lib file or .dll file ? if yes, how do i make a linking of it ?

error occur when i try to link the program, it said undefine symbol SOCKET in mysock.cpp

how should i solve that ?
0
Comment
Question by:tsung
[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 1

Expert Comment

by:_Zaphod
ID: 1257898
You need to link wsock32.lib or winsock.lib, depending on your compiler.
0
 

Author Comment

by:tsung
ID: 1257899
How should i make the linkage for the winsock.lib to my program if i'm using the borland c++ 4.5 compiler ?
0
 
LVL 2

Expert Comment

by:kellyjj
ID: 1257900
This is proboly a dumb question but you do have SOCKET defined somewhere??  I use borland 4.5  I will see if I can't figure out how to do the linking.
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:tsung
ID: 1257901
I checked the winsock.h header file and there is a line of code ---> typedef unsigned int SOCKET
been defined in the header file.

is there any others possibility which cause this problem ?
0
 
LVL 4

Expert Comment

by:jtwine100697
ID: 1257902
  Search through your includes and code for any "strange" uses of "SOCKET".  It is just supposed to be a variable (uint).  But since you are getting linker errors, the compiler thinks that SOCKET is a function or some other block of code.

-=- James.

0
 
LVL 1

Expert Comment

by:_Zaphod
ID: 1257903
Linking winsock.lib or wsock32.lib didn't help? All socket symbols are defined there.
0
 

Author Comment

by:tsung
ID: 1257904
I have try the same program and same libraries and it work on MSVC 5.0. But how come Borland C can't do it ?
0
 
LVL 1

Expert Comment

by:_Zaphod
ID: 1257905
You never know the mysterious ways of compilers/linkers - what they include by default, what they include when they see something's missing, et cetera
0
 
LVL 2

Expert Comment

by:Slarti
ID: 1257906
This sounds like a serious question. Why don't you increase the points to 50 (at least)?
0
 

Accepted Solution

by:
jhjeon earned 0 total points
ID: 1257907
do you use 16bit API...?
Borland 4.x Linking is Differ

http://www.goodnet.com/~esnible/winsock.html

"Note that it doesn't matter whose Winsock you are using, the same .LIB file works with all 16 bit programs, and you don't need a .LIB for 32 bit programs. Also note that these versions are a bit more recent than the version in the WINSOCK.HLP normally shipped with BC++.
If you are using Borland C++ 4.0 you got a free WINSOCK.HLP and WINSOCK.H, but no WINSOCK.DLL, so your programs can't link. You can use the provided IMPLIB to make a WINSOCK.LIB from your WINSOCK.DLL."


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

Suggested Solutions

Title # Comments Views Activity
How to set environment variables in C 2 101
Computer slow / BSOD 10 78
Display a Float Variable in C without using the function printf. 2 46
maximize the sum of fractions 33 74
This tutorial is posted by Aaron Wojnowski, administrator at SDKExpert.net.  To view more iPhone tutorials, visit www.sdkexpert.net. This is a very simple tutorial on finding the user's current location easily. In this tutorial, you will learn ho…
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.
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.

739 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