[comp.sys.att] 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

bes@holin.ATT.COM (Bradley Smith) (06/24/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.
> 
> The command I used was 
> $ ld /lib/crt0s.o /lib/shlib.ifile *.o -lcurses

Try using /bin/ccc (it was posted a while ago).  It makes a shell
script which allows one to use curses with shlib.


-- 
Bradley Smith				{ihnp4,mtune,etc...}!holin!bes
AT&T DSG Holmdel, NJ			HO 2L-227
201-949-0090 / Cornet 233-0090
-- 
Bradley Smith				{ihnp4,mtune,etc...}!holin!bes
AT&T DSG Holmdel, NJ			HO 2L-227
201-949-0090 / Cornet 233-0090

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              |
+------------------------------------+----------------------------------------+

bes@holin.ATT.COM (Bradley Smith) (06/27/88)

In article <201@elgar.UUCP>, ford@elgar.UUCP (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?
> 
> other.  Curses and Tam can not be linked into the same program because
> they have functions with identical names that do different things.

try using /bin/ccc (which was posted a-while ago), it works well.
-- 
Bradley Smith				{ihnp4,mtune,etc...}!holin!bes
AT&T DSG Holmdel, NJ			HO 2L-227
201-949-0090 / Cornet 233-0090

dca@kesmai.COM (David C. Albrecht) (06/29/88)

In article <201@elgar.UUCP>, ford@elgar.UUCP (Mike "Ford" Ditto) writes:
> 
> 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.
> 
> 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.
> 
Well, using the shared library should reduce the size of your executable
even if you don't substitute TAM functions for curses functions.  I would
think you should be able to make a local copy of the shlib.ifile with
your executable and edit out any entries in the file that collide with
curses symbols.  Then you wouldn't have to give up the size savings for
non-curses routines.

Anybody know how to force a physical scroll with curses?  I have wm
half-way working and it really burns me that no matter what I do the
stupid curses won't use the hardware scroll even for full-size screens.
Really slows it down.

David Albrecht

wilber@alice.UUCP (07/10/88)

David Albrecht writes:
}In article <201@elgar.UUCP>, ford@elgar.UUCP (Mike "Ford" Ditto) writes:
}> 
}> 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.
}> ...
}Well, using the shared library should reduce the size of your executable
}even if you don't substitute TAM functions for curses functions.  I would
}think you should be able to make a local copy of the shlib.ifile with
}your executable and edit out any entries in the file that collide with
}curses symbols.  Then you wouldn't have to give up the size savings for
}non-curses routines.

Mr. Albrecht is correct.  There is a nice little package called "ccc" written
by Jeffrey Small and Arnold Robbins (with some code from Emnet Gray) that
provides a pleasant interface for using the shared libraries.  When you install
it a new .ifile is created in which all the TAM functions have been renamed (by
prepending an "x").  (The old .ifile is also kept.)  The package includes a
shell script ("ccc" itself) that automatically uses the new .ifile when you use
the -lcurses option (so there are no name conflicts) and otherwise uses the
original .ifile.  So you can compile programs that use Curses with the shared
libraries, although of course the Curses routines themselves are not shared.
If you're willing to use funny names for the TAM functions (xinitscr, xnoecho,
etc.)  you should even be able to mix Curses and TAM in the same program
(although I haven't tried it).  Naturally you shouldn't use both systems at
once on the same screen but I can imagine an ambitious hacker writing a
program that uses TAM when it's using the 3b1 monitor and Curses otherwise.

Ccc is free (at least there's no copyright on it, and it was posted to the
net).  It's archived on killer and if you can't get it any other way send
me E-mail (to my HOME machine) and I'll send you a copy.

}Anybody know how to force a physical scroll with curses?  I have wm
}half-way working and it really burns me that no matter what I do the
}stupid curses won't use the hardware scroll even for full-size screens.
}Really slows it down.

I don't think there's any way to do this in Curses.  They don't call it Curses
for nothing, ya know.

Bob Wilber   Work: UUCP: {allegra, mtune, ihnp4}!gauss!wilber
                   ARPA: wilber@research.att.com
             Home: UUCP: {allegra, mtune, ihnp4}!gauss!heaven!wilber
                   ARPA: heaven!wilber%gauss@att.arpa