Board index » cppbuilder » Building a library with command line tools?

Building a library with command line tools?


2004-04-14 01:45:29 AM
cppbuilder41
I'm working on a small project where I am using open source code
provided as both source and a Microsoft DLL. While I was able to
access the DLL functions after appropriate use of coff2omf, I decided
to dispense with the hassle of using a DLL for such a small project and
built my own libraries with Tlib. While I successfully compiled the project
with the library I built, I am not sure if I the library I built is the best
it
could be because I got this compiler warning:
Quote
Turbo Incremental Link 5.00 Copyright (c) 1997, 2000 Borland
! Error: Unresolved external 'WinMain' referenced from
C:\BORLAND\BCC55\LIB\C0W32.OBJ
Apparently this was not a fatal flaw, because the object files which were
created were fine, so Tlib built a library with them without any problems.
But, it got me to wondering about what the correct procedures are for
building a library with command line tools. The only help I found at BDN
had to do with running a wizard not available with the CL tools. So if
anyone
can point me to information on procedures to build libraries, I would
appreciate it.
Thanks,
Bill
 
 

Re:Building a library with command line tools?

Quote
Turbo Incremental Link 5.00 Copyright (c) 1997, 2000 Borland
! Error: Unresolved external 'WinMain' referenced from
C:\BORLAND\BCC55\LIB\C0W32.OBJ
That error is not related to the libraries. It relates to how the
compiler or linker was called.
The error says that you built the application as a Windows GUI program
(a Graphical User Interface program) but did not have the function
WinMain which is where a Windows GUI program begins processing.
It could have been that you'd intended to create a Windows Console
Mode program (a text mode program), one which begins at the function
main but failed to provide the -WC or -tWC option on the bcc32 command
line or, if linking yourself, by providing c0w32.obj instead of
c0x32.obj as the startup code.
Quote
... So if anyone can point me to information on procedures
to build libraries, I would appreciate it.
You are the procedure. You build libraries by hand, with a command
line or with a batch file containing command lines or with command
lines in a make file.
Here is an example of a make file that will build a library from
several files.
---------------------------------
.autodepend
.cpp.obj :
bcc32 -c -W -v { $<}
.c.obj :
bcc32 -c -W -v { $<}
.asm.obj :
tasm32 /ZI /L $<
MyLib.lib : file1.obj file2.obj file3.obj file4.obj file5.obj \
file6.obj file7.obj
tlib /C mylib.lib @&&|
-+file1.obj -+file2.obj -+file3.obj &
-+file4.obj -+file5.obj -+file6.obj &
-+file7.obj , mylib.lst
|
---------------------------------
. Ed
Quote
Bill Carson wrote in message
news: XXXX@XXXXX.COM ...

I'm working on a small project where I am using open
source code provided as both source and a Microsoft
DLL. While I was able to access the DLL functions after
appropriate use of coff2omf, I decided to dispense with
the hassle of using a DLL for such a small project and
built my own libraries with Tlib. While I successfully
compiled the project with the library I built, I am not
sure if I the library I built is the best it
could be because I got this compiler warning:

>Turbo Incremental Link 5.00 Copyright (c) 1997, 2000 Borland
! Error: Unresolved external 'WinMain' referenced from
C:\BORLAND\BCC55\LIB\C0W32.OBJ

Apparently this was not a fatal flaw, because the object
files which were created were fine, so Tlib built a library
with them without any problems. But, it got me to wondering
about what the correct procedures are for building a library
with command line tools. The only help I found at BDN
had to do with running a wizard not available with the CL
tools. So if anyone can point me to information on procedures
to build libraries, I would appreciate it.
 

Re:Building a library with command line tools?

Quote
It could have been that you'd intended to create a Windows Console
Mode program (a text mode program), one which begins at the function
main but failed to provide the -WC or -tWC option on the bcc32 command
line or, if linking yourself, by providing c0w32.obj instead of
c0x32.obj as the startup code.
Actually, I just compiled with some preset compiler options in my IDE,
so I didn't give it much thought (obviously!). So, when I saw that the
object files were created anyway, I just fed them to Tlib which didn't
complain when it built the library.
Which leads to the question: what compiler options should I use when all
I want are the object files? If I am interpreting the make file example
you
gave then it looks like if I just use -c (Compile to .OBJ, no link), -W
and -v
then I will get what I need. Since tasm.exe isn't distributed with the CL
tools,
then I assume I can ignore it? If I wanted a library for a non-Windows
application then would I leave out the -W switch?
Thanks,
Bill
 

{smallsort}

Re:Building a library with command line tools?

The error was from linking, not from building a library. If you got
that error in the IDE then you had somehow arranged to link, not
build a library. I don't build libraries from the IDE, never have, so
can't tell you what might have gone wrong. You might ask about
it in the IDE group, borland.public.cppbuilder.ide
To see the command line options for the compiler
Start the help
Click on the Index tab
Type BCC32 into the edit control
Click the Display button
For the liker repeat the above with ILINK32 in the edit control.
The compiler will call the linker to finish the build unless you tell
it to
only compile with a -c or /c option.
To build for Windows Console mode give -WC. For Windows GUI
mode use -W. -tWC and -tW also work.
The -v option tells it to generate debug info, the same as Tasm32's
/ZI option (or any of -zi, /zi or -ZI), Tasm's command line options
are
not case sensitive. The compiler and linker's options are case
sensitive.
The Console vs GUI option effects how the link is done. While
I've the habit of using it all the time, it really only matters for
the
compiler when you are allowing the compiler to call the linker itself.
Quote
... Since tasm.exe isn't distributed with the CL tools...
My copy of Tasm32.exe came with C++ Builder. It depends upon
which edition you bought. You obviously did not get the free
downloaded tools, the ones from Builder 5, because they do not
come with an IDE and you are using the IDE.
. Ed
Quote
Bill Carson wrote in message
news: XXXX@XXXXX.COM ...

Actually, I just compiled with some preset compiler options
in my IDE, so I didn't give it much thought (obviously!). So,
when I saw that the object files were created anyway, I just
fed them to Tlib which didn't complain when it built the library.

Which leads to the question: what compiler options should I
use when all I want are the object files? If I am interpreting
the make file example you gave then it looks like if I just use
-c (Compile to .OBJ, no link), -W and -v then I will get what I
need. Since tasm.exe isn't distributed with the CL tools,
then I assume I can ignore it? If I wanted a library for a
non-Windows application then would I leave out the -W switch?
 

Re:Building a library with command line tools?

Quote
The error was from linking, not from building a library. If you got
that error in the IDE then you had somehow arranged to link, not
build a library.
Right, I did call for a link, so I can ignore the error. The object files
were apparently alright because Tlib was able to build a library
from them. I was looking at the help file for Ilink32 and it lists a
switch (/Gl) that apparently forces it to only(?) build a library. But,
I have experimented with this switch and still have yet to get it to
work, probably because I still don't have my IDE set up right yet.
Quote
I don't build libraries from the IDE, never have, so
can't tell you what might have gone wrong. You might ask about
it in the IDE group, borland.public.cppbuilder.ide
I should have mentioned I'm not using the Borland IDE. I am
using VIDE from: www.objectcentral.com/ which
has support for the free Borland Command Line compiler.
Quote
The compiler will call the linker to finish the build unless you tell
it to only compile with a -c or /c option.
According to output from my IDE, even when I use the -c option, it
still calls the linker, but this may be a problem with the makefile my IDE
is producing. I am still working the issue ( guess its about time I learned
about makefiles!). Anyway, if I am interpreting the /Gl switch for the
linker correctly, maybe I still want to call the linker to have it build the
library?
Quote
To build for Windows Console mode give -WC. For Windows GUI
mode use -W. -tWC and -tW also work.
Because all I want is a library that is built from straight C code source,
I am wondering if I really need to tell the compiler whether I want
a console or gui? I assume the library can be used for either a
Windows or command line application (DOS, Linux), so I don't
see why these options matter. But, I understand as you stated:
Quote
The Console vs GUI option effects how the link is done.
Thanks,
Bill
 

Re:Building a library with command line tools?

Bill Carson wrote:
Quote
Right, I did call for a link, so I can ignore the error. The object files
were apparently alright because Tlib was able to build a library
from them. I was looking at the help file for Ilink32 and it lists a
switch (/Gl) that apparently forces it to only(?) build a library. But,
Doesn't say, but I'd bet it's to create a lib for the DLL that you are
linking. Since you aren't creating a DLL, this isn't what you want.