Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Borland Tlinker problem

Posted on 1997-12-03
7
Medium Priority
?
451 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
[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
  • 4
  • 3
7 Comments
 
LVL 11

Accepted Solution

by:
alexo earned 400 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
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!

 

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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

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…
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…
The goal of this video is to provide viewers with basic examples to understand recursion in the C programming language.
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.

604 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