[unix-pc.general] shlib and curses on unix pc

tkacik@rphroy.UUCP (Tom Tkacik) (06/23/88)

Has anyone managed to compile a program that uses curses,
with the shared library.  I tried it and it does not seem to work.

The command I used was 
$ ld /lib/crt0s.o /lib/shlib.ifile *.o -lcurses

First, I got many messages stating that curses had redefined symbols.
These, I suspect, are also defined in the shared library.
Though, if I leave off the -lcurses, there are a lot of undefined
symbols.

Then, after letting the link continue, it turned out that 
_doprnt (among others) was undefined, (ie. not in the shared library,
though in /lib/libc.a).
I added -lc to the link command to see if it would add the missing routines,
without causing any other problems, but that did not work.
I got more messages about redefined symbols.
It did link though.

However, the created file was significantly larger than without the
shared library, (190K vs 150K), not smaller.
And when I ran it, I got a core dump.

It appears that the shared library contains some of -lcurses, but not all
of -lc.

Any help would be appreciated.

Tom Tkacik
tkacik@gmr.com

ford@elgar.UUCP (Mike "Ford" Ditto) (06/25/88)

In article <559@rphroy.UUCP> tkacik@rphroy.UUCP (Tom Tkacik) writes:
>Has anyone managed to compile a program that uses curses,
>with the shared library.  I tried it and it does not seem to work.

Who ever said it would?

>The command I used was 
>$ ld /lib/crt0s.o /lib/shlib.ifile *.o -lcurses
>
>First, I got many messages stating that curses had redefined symbols.
>These, I suspect, are also defined in the shared library.
>Though, if I leave off the -lcurses, there are a lot of undefined
>symbols.

This has been covered before, but I'll summarize again:

The Unix PC shared library includes TAM (the Terminal Access Method),
*NOT* Curses.  This fact, along with a complete description of TAM, is
given in the Unix Utilities documentation.  Tam is a curses-like
package with a bunch of windowing enhancements, and subset of the
curses functions provided to ease porting of curses programs.

If you want the shared library, use Tam.  If you have a curses
program, and it uses curses functions that are not also in Tam, don't
use the shared library.

Some people have used a few simple curses functions from -lcurses in a
Tam program linked with the shared-library.  The functions that I
remember being used were functions like cbreak(), noecho(), and nonl(),
which are not closely interdependent with the rest of curses (they
just manipulate the stty modes.)  This is by no means supported or
reliable.

Basically, the shared library is equivalent to the following ld
options: -ltam -ltermlib -lc.  The same rules apply to shlib as apply
to normal libraries: You can link in any combination of libraries as
long as they do not have global symbols with names that conflict with
other.  Curses and Tam can not be linked into the same program because
they have functions with identical names that do different things.

					-=] Ford [=-

"Once there were parking lots,		(In Real Life:  Mike Ditto)
now it's a peaceful oasis.		ford@kenobi.cts.com
This was a Pizza Hut,			...!sdcsvax!crash!kenobi!ford
now it's all covered with daisies." -- Talking Heads

jcs@tarkus.UUCP (John C. Sucilla) (06/25/88)

In article <559@rphroy.UUCP> tkacik@rphroy.UUCP (Tom Tkacik) writes:
>Has anyone managed to compile a program that uses curses,
>with the shared library.  I tried it and it does not seem to work.

Make sure you have the Curses/Terminfo Programmers Package installed.
It's part of the Development set.  The Curses package that is part of
the Foundation Set don't cut it.
-- 
John "C". Sucilla,  A silicon based life form.
       {ihnp4,chinet,ddsw1}!tarkus!jcs
  You have a better idea? Now's the time..

kid@june.cs.washington.edu (Bob Mitchell) (06/26/88)

Actually, you can use the shared library with curses.  But first you have
to create a new ifile by editting the tam functions out of
/lib/shlibc.ifile.  This will give you access to only the termlib and c
library parts of shlib.  You can then link using:

		ld *.o /lib/crt0s.o -lcurses shcterm.ifile

where shcterm.ifile is the name of the new ifile.  Linking will give
warnings about redefining PC, UP, BC, and ospeed - but this is fine, as
long as the program does not use non-zero initializers for them.

				Bob Mitchell

uucp: ...!uw-beaver!uw-june!kid
arpanet: kid@cs.washington.edu

gil@limbic.UUCP (Gil Kloepfer Jr.) (06/26/88)

In article <201@elgar.UUCP> ford@kenobi.cts.com (Mike "Ford" Ditto) writes:
|>In article <559@rphroy.UUCP> tkacik@rphroy.UUCP (Tom Tkacik) writes:
|>>Has anyone managed to compile a program that uses curses,
|>>with the shared library.  I tried it and it does not seem to work.
|>
|>Who ever said it would?

Nah, it doesn't work unless you make a kludged shlib.ifile.

You can copy the shlib.ifile to say, shlib-c.ifile, and remove all the
lines from the shlib-c.ifile that are duplicates in curses.  Then link
with:

     $ ld /lib/crt0s.o /lib/shlib-c.ifile *.o -lcurses

This should work so long as you don't need any tam stuff too (why would you
need both I guess :-).  I think I remember having to do it before to
something (Lenny, remember what it was???) in order for it to link this
way (I like using the shlib since the resultant object code is smaller).

No guarantees on this (ie. this is semi-flameproof :-) .. but I believe I
used it once and it works.  REMEMBER!!  DO NOT CHANGE "shlib" OR THE ORIGINAL
"shlib.ifile" .. IF YOU DO, YOUR SYSTEM WILL DO ALMOST NOTHING!  You will
have to go to the floppies and do some other unmentionable kludging to get
the system running again!

+------------------------------------+----------------------------------------+
| Gil Kloepfer, Jr.                  | Net-Address:                           |
| ICUS Software Systems              | {boulder,talcott}!icus!limbic!gil      |
| P.O. Box 1                         | Voice-net: (516) 968-6860              |
| Islip Terrace, New York  11752     | Othernet: gil@limbic.UUCP              |
+------------------------------------+----------------------------------------+