Board index » cppbuilder » Socket SetPort Linker Error

Socket SetPort Linker Error


2003-08-28 12:32:04 AM
cppbuilder35
Hello,everyone:
I am using sockets to build a internet application. I put both Server
socket and Client socket into one project. However whenever I specify a port
to server and client, I got a link error. I did include <winsock.h>file.
Here is what I added to my program:
"ServerSocket1->Close();"
"ServerSocket1->port = 5000" ...
...
"ClientSocket1->Close();"
"ClientSocket1->port=5000"...
The link error is :
"[Linker Error] Unresolved external'_fastcall
Scktcomp::TAbstractSocket::SetPortA(int) referenced from D:\...\MAIN.OBJ"
Any suggestions will be very appraciated.
Kevin
 
 

Re:Socket SetPort Linker Error

Kevin wrote:
Quote
Hello,everyone:
I am using sockets to build a internet application. I put both Server
socket and Client socket into one project. However whenever I specify a port
to server and client, I got a link error. I did include <winsock.h>file.
Here is what I added to my program:
"ServerSocket1->Close();"
"ServerSocket1->port = 5000" ...
...
"ClientSocket1->Close();"
"ClientSocket1->port=5000"...

The link error is :
"[Linker Error] Unresolved external'_fastcall
Scktcomp::TAbstractSocket::SetPortA(int) referenced from D:\...\MAIN.OBJ"

Any suggestions will be very appraciated.
The problem is that the Scktcomp VCL class (which you must be including in some kind
of possibly nearly invisible way) has a member function called "SetPort".
This would be okay in a perfect world, but Win32 is not a perfect world - it is
Microsoft's world. And in that world, they decided to use SetPort as a Win32 api
entry point.
Okay, you say, but what is this SetPortA? When you compile a Win32 app, you can
compile it for ANSI or UNICODE character set. Normally, if you don't do anything
(ie., define UNICODE), you get the ANSI entry points. Here's the include file
lines in winspool.h:
#ifdef UNICODE
#define SetPort SetPortW
#else
#define SetPort SetPortA
#endif
You need 2 different entry points depending on whether you are using UNICODE (with
its 16bit characters) or ANSI, with its 8 bit characters. Of course, this sort
of code in a header file breaks anyone who tries to use their own SetPort, as you
can see in scktcomp.hpp in your VCL include directory.
What does all this mean? Borland has to fix their header file to not use SetPort
(remember, this is Microsoft's imperfect world). But until then, I think the
best way out of this is for you to personally edit scktcomp.hpp and, after all the
include files, add:
#undef SetPort
It's ugly, it'll get overwritten on an upgrade, and it isn't very fun, but I think
it is the easiest and most straightforward way to do it. Oh, and be sure to report
this "bug" to Borland on the web site so it'll get fixed next upgrade.
--
Jonathan Arnold C/C++/CBuilder Keen Advice:
www.keen.com/categories/categorylist_expand.asp
Comprehensive C++Builder link site:
www.buddydog.org/C++Builder/c++builder.html
 

Re:Socket SetPort Linker Error

"Kevin" < XXXX@XXXXX.COM >wrote in message
Quote
The link error is :
"[Linker Error] Unresolved external'_fastcall
Scktcomp::TAbstractSocket::SetPortA(int) referenced
from D:\...\MAIN.OBJ"
bdn.borland.com/article/0,1410,19474,00.html
bdn.borland.com/article/0,1410,20125,00.html
bdn.borland.com/article/0,1410,21494,00.html
Gambit
---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (www.grisoft.com).
Version: 6.0.512 / Virus Database: 309 - Release Date: 8/19/03
 

{smallsort}