Solved

Borland Tlinker problem

Posted on 1997-12-03
7
416 Views
Last Modified: 2008-02-01

Hello folks,

I am trying to compile a winsock application using Borland's make version 3.6 and even
though I believe I have created the dependencies right and I have given the right
parameters the TLINK linker still cannot link correctly functions that are in separate
modules and in libraries.

My project is made of three programs (ac_ftp.c, ftp_ctrl.c and ftp_data.c), a resource
file (ac_ftp.rc), a definition file (ac_ftp.def) and two non-standard library
(winsock.lib and winsockx.h).  The functions in ftp_ctrl.c and ftp_data.c, as well as
those in the two libraries, are not being found at link time.

The library paths are correct and the c source files and resource file compile just fine
if I initiate an MS-DOS session from windows 3.11.  To make things more strange, if I
issue the make command from DOS (no Windows session), nothing will compile.

Enclosed is the makefile and the errormessages obtained. Any help will behighly
appreciated.

Regards,

Felipe Guacache

---------------------------------------------------------------------------------------------------------------------------------------
#makefile

.AUTODEPEND

.PATH.obj = .

#               *Translator Definitions*
CC = bcc +AC_FTP.CFG
TASM = TASM
TLIB = tlib
TLINK = tlink
LIBPATH = C:\UTIL\BORLANDC\LIB;..\LIB
INCLUDEPATH = C:\UTIL\BORLANDC\INCLUDE;..\INCLUDE


#               *Implicit Rules*
.c.obj:
  $(CC) -c {$< }

.cpp.obj:
  $(CC) -c {$< }

#               *List Macros*
Link_Exclude =  \
 .\ac_ftp.res

Link_Include =  \
 ac_ftp.obj \
 ftp_ctrl.obj \
 ftp_data.obj \
 ac_ftp.def

#               *Explicit Rules*
.\ac_ftp.exe: ac_ftp.cfg $(Link_Include) $(Link_Exclude)
  $(TLINK) /v/x/c/P=61440/A=16/Twe/L$(LIBPATH) @&&|
c0ws.obj+
.\ac_ftp.obj+
.\ftp_ctrl.obj+
.\ftp_data.obj
.\ac_ftp
nul                # no map file
winsock.lib+
winsockx.lib+
mathws.lib+
import.lib+
cws.lib
ac_ftp.def
|
  RC  .\ac_ftp.res .\ac_ftp.exe


#               *Individual File Dependencies*
ac_ftp.obj: ac_ftp.cfg ac_ftp.c

ftp_ctrl.obj: ac_ftp.cfg ftp_ctrl.c

ftp_data.obj: ac_ftp.cfg ftp_data.c

.\ac_ftp.res: ac_ftp.cfg ac_ftp.rc
      RC -R -I$(INCLUDEPATH) -FO .\ac_ftp.res AC_FTP.RC

#               *Compiler Configuration File*
ac_ftp.cfg: makefile
  copy &&|
-R
-2
-u
-v
-W
-vi-
-wpro
-weas
-wpre
-n.
-I$(INCLUDEPATH)
-L$(LIBPATH)
-P
| ac_ftp.cfg

---------------------------------------------------------------------------------------------------------------------------------------
#Error Messages

MAKE Version 3.6  Copyright (c) 1992 Borland International

Available memory 43917312 bytes

        bcc +AC_FTP.CFG -c ac_ftp.c ftp_ctrl.c ftp_data.c
Borland C++  Version 3.1 Copyright (c) 1992 Borland International
ac_ftp.c:
Warning ac_ftp.c 552: 'lRet' is assigned a value that is never used in function pascal
Dlg_Main(const HWND__ *,unsigned int,unsigned int,long)
Warning ac_ftp.c 552: 'nAddrSize' is assigned a value that is never used in function
pascal Dlg_Main(const HWND__ *,unsigned int,unsigned int,long)
ftp_ctrl.c:
ftp_data.c:
Warning ftp_data.c 147: Constant out of range in comparison in function
AcceptDataConn(unsigned int,sockaddr_in *)

        Available memory 3695252
        RC -R -IC:\UTIL\BORLANDC\INCLUDE;..\INCLUDE -FO .\ac_ftp.res AC_FTP.RC
Microsoft (R) Windows Resource Compiler  Version 3.10
Copyright (C) Microsoft Corp. 1985-1992.  All rights reserved.

        tlink /v/x/c/P=61440/A=16/Twe/LC:\UTIL\BORLANDC\LIB;..\LIB @MAKE0000.$$$
Turbo Link  Version 5.1 Copyright (c) 1992 Borland International
Warning: Stack size is less than 1400h.  It has been reset to 1400h.
Error: Undefined symbol getaddr(char far*) in module ac_ftp.c
Error: Undefined symbol wsaperror(int,char far*,const void near*) in module ac_ftp.c
Error: Undefined symbol dlg_about(const hwnd__near*,unsigned int,unsigned int,long) in
module ac_ftp.c
Error: Undefined symbol initdataconn(sockaddr_in near*,const hwnd__near*,unsigned int)
in module ac_ftp.c
Error: Undefined symbol createlclfile(char far*) in module ac_ftp.c
Error: Undefined symbol dlg_file(const hwnd__near*,unsigned int,unsigned int,long) in
module ac_ftp.c
Error: Undefined symbol getlcldir(char far*) in module ac_ftp.c
Error: Undefined symbol initctrlconn(sockaddr_in near*,const hwnd__near*,unsigned int)
in module ac_ftp.c
Error: Undefined symbol centerwnd(const hwnd__near*,const hwnd__near*,int) in module
ac_ftp.c
Error: Undefined symbol wsaperror(int,char far*,unsigned int) in module ftp_ctrl.c
Error: Undefined symbol closeftpconn(unsigned int near*,char far*,int,unsigned int) in
module ftp_ctrl.c
Error: Undefined symbol getbuf(unsigned int,int,int) in module ftp_data.c
Error: Undefined symbol gethostid() in module ftp_data.c

** error 1 ** deleting .\ac_ftp.exe
0
Comment
Question by:guaco
  • 4
  • 3
7 Comments
 
LVL 11

Accepted Solution

by:
alexo earned 100 total points
ID: 1256493
Error: Undefined symbol getaddr(char far*) in module ac_ftp.c
                        ^^^^^^^

Here's your problem.

The C calling convention prepends an underscore to the function name, so the function name in the winsock library is actually "_getaddr".

Somehow, when compiling ac_ftp.c, your compiler decided that getaddr() uses a different function calling convention, one that does not prepend an underscore (say, Pascal?).

The linker is right to complain.  The problem is in the compilation.  Check the compile switches.

0
 

Author Comment

by:guaco
ID: 1256494
You were right, (thanks a lot!). I forgot to mention that I was compiling as C++. I changed that and immediatly all the errors about undefined variables went away.  However, I now got another problem: one of the modules in winsockx.lib is calling wsprintf as _wsprintf and the linker cannot figure that one out. What can I do other then rebuilding the library(which I can't since I do not have the source code).

Here is the new error file.
---------------------------------------------------------------
MAKE Version 3.6  Copyright (c) 1992 Borland International

Available memory 48263168 bytes

        bcc +AC_FTP.CFG -c ac_ftp.c ftp_ctrl.c ftp_data.c
Borland C++  Version 3.1 Copyright (c) 1992 Borland International
ac_ftp.c:
Warning ac_ftp.c 552: 'lRet' is assigned a value that is never used in function Dlg_Main
Warning ac_ftp.c 552: 'nAddrSize' is assigned a value that is never used in function Dlg_Main
ftp_ctrl.c:
ftp_data.c:
Warning ftp_data.c 147: Constant out of range in comparison in function AcceptDataConn

        Available memory 3760984
        RC -R -IC:\UTIL\BORLANDC\INCLUDE;..\INCLUDE -FO .\ac_ftp.res AC_FTP.RC
Microsoft (R) Windows Resource Compiler  Version 3.10
Copyright (C) Microsoft Corp. 1985-1992.  All rights reserved.

        tlink /v/s/c/P-/Twe/LC:\UTIL\BORLANDC\LIB;..\LIB @MAKE0000.$$$
Turbo Link  Version 5.1 Copyright (c) 1992 Borland International
Warning: Stack size is less than 1400h.  It has been reset to 1400h.
Error: Undefined symbol _wsprintf in library file winsockx.lib in module wsa_err.c

** error 1 ** deleting .\ac_ftp.exe

0
 
LVL 11

Expert Comment

by:alexo
ID: 1256495
Did you #include <windows.h> in wsa_err.c?

Actually, there is no wsprintf() function.  wsprintf is a #define that resolves to either wsprintfA or wsprintfW depending on whether your application is ASCII or unicode.

Your linker is right again (one smart linker you have there).

0
Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

 

Author Comment

by:guaco
ID: 1256496
I did not code either the module wsa_err.c or the library winsockx.h and do not have the source code.  My question was, again, how to avoid the problem without having to recompile winsockx.h.  Any ideas?

Thanks!
0
 
LVL 11

Expert Comment

by:alexo
ID: 1256497
Where did you get winsockx.lib from?
Is it by any chance a library designed for 16-bit windows 3.x?

If you're compiling for Win3.x, disregard my comment about wsprintf().  You probably forgot to include a library in your app.  Try LIBW.LIB or something similar.

0
 

Author Comment

by:guaco
ID: 1256498
Yes, it is a 16-bit windows 3.1x library.  The right library was CWM.LIB.  By editing it I noticed all the symbols were in uppercase, the linker has an option to omit case I set it and it linked just fine.  Thanks for the good pointer Alexo.

Cheers,

Felipe
0
 
LVL 11

Expert Comment

by:alexo
ID: 1256499
No problem.  Have fun!
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

Suggested Solutions

Title # Comments Views Activity
Absolute madness with managing time in C 4 80
How to organize data in excel ? 2 106
Want to delete all my personal data 13 127
Need example 5 100
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…
This is a short and sweet, but (hopefully) to the point article. There seems to be some fundamental misunderstanding about the function prototype for the "main" function in C and C++, more specifically what type this function should return. I see so…
The goal of this video is to provide viewers with basic examples to understand how to use strings and some functions related to them in the C programming language.
Video by: Grant
The goal of this video is to provide viewers with basic examples to understand and use nested-loops in the C programming language.

708 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