* Creating shared libraries
@ 1995-12-12 5:00 Scott Tringali
1995-12-13 5:00 ` Jochen Klein
1995-12-15 5:00 ` Tim Lucia
0 siblings, 2 replies; 8+ messages in thread
From: Scott Tringali @ 1995-12-12 5:00 UTC (permalink / raw)
How do I create my own shared libraries? I am working with a large (30+)
number of applications that have many common libraries. These are created with
cc -c, then ar, and then linked into the final application with cc.
Is there any way I can take these libraries, compile them to a .so, and save on
disk space and memory? I haven't found any references how to do this in the cc
or ld man pages.
--
Scott J. Tringali, tringali@ultranet.com
Raytheon Electronic Systems, International Air Traffic Control
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: Creating shared libraries
1995-12-12 5:00 Creating shared libraries Scott Tringali
@ 1995-12-13 5:00 ` Jochen Klein
1995-12-15 5:00 ` Tim Lucia
1 sibling, 0 replies; 8+ messages in thread
From: Jochen Klein @ 1995-12-13 5:00 UTC (permalink / raw)
try:
%.so: %.a
ld -shared -expect_unresolved "*" -all $< -o $@
BTH: Is in 'man ld'.
--
'''
(o o)
+-----------------+------------ooO-(_)-Ooo-----------------------------------+
| Jochen Klein | Jochen.Klein@informatik.uni-karlsruhe.de
|
| Striederstr. 11 | s_klein@ira.uka.de
|
| 76131 karlsruhe | klein@telematik.informatik.uni-karlsruhe.de
|
| 0721 / 61 31 10 |
http://www.telematik.informatik.uni-karlsruhe.de/~klein |
+-----------------+----------------------------------------------------------+
| char *p="char *p=%c%s%c;%cmain(){printf(p,34,p,34,10,10);}%c";
|
| main(){printf(p,34,p,34,10,10);}
|
+----------------------------------------------------------------------------+
^ permalink raw reply [flat|nested] 8+ messages in thread* Re: Creating shared libraries
1995-12-12 5:00 Creating shared libraries Scott Tringali
1995-12-13 5:00 ` Jochen Klein
@ 1995-12-15 5:00 ` Tim Lucia
1995-12-18 5:00 ` Tim Lucia
1 sibling, 1 reply; 8+ messages in thread
From: Tim Lucia @ 1995-12-15 5:00 UTC (permalink / raw)
In article <4ak145$7t4@news.res.ray.com>, tringali@news.ed.ray.com (Scott Tringali) writes:
|>How do I create my own shared libraries? I am working with a large (30+)
|>number of applications that have many common libraries. These are created with
|>cc -c, then ar, and then linked into the final application with cc.
|>
|>Is there any way I can take these libraries, compile them to a .so, and save on
|>disk space and memory? I haven't found any references how to do this in the cc
|>or ld man pages.
|>
You didn't look hard enough. It is in the ld(1) manual page:
NAME
ld, uld - link editor and ucode link editor
SYNOPSIS
ld [ option ... ] file ...
uld [ option ... ] file ...
DESCRIPTION
The ld command invokes the DEC OSF/1 link editor which links extended coff
object files. The archive format understood by ld is the one created by
the archiver ar(1).
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: Creating shared libraries
1995-12-15 5:00 ` Tim Lucia
@ 1995-12-18 5:00 ` Tim Lucia
1995-12-18 5:00 ` Tim Lucia
0 siblings, 1 reply; 8+ messages in thread
From: Tim Lucia @ 1995-12-18 5:00 UTC (permalink / raw)
Hmm. My previous post got truncated. What I meant to say was:
In article <4ak145$7t4@news.res.ray.com>, tringali@news.ed.ray.com (Scott Tringali) writes:
|>How do I create my own shared libraries? I am working with a large (30+)
|>number of applications that have many common libraries. These are created with
|>cc -c, then ar, and then linked into the final application with cc.
|>
|>Is there any way I can take these libraries, compile them to a .so, and save on
|>disk space and memory? I haven't found any references how to do this in the cc
|>or ld man pages.
|>
You didn't look hard enough. It is in the ld(1) manual page:
NAME
ld, uld - link editor and ucode link editor
SYNOPSIS
ld [ option ... ] file ...
uld [ option ... ] file ...
DESCRIPTION
The ld command invokes the DEC OSF/1 link editor which links extended coff
object files. The archive format understood by ld is the one created by
the archiver ar(1).
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: Creating shared libraries
1995-12-18 5:00 ` Tim Lucia
@ 1995-12-18 5:00 ` Tim Lucia
0 siblings, 0 replies; 8+ messages in thread
From: Tim Lucia @ 1995-12-18 5:00 UTC (permalink / raw)
ARGH! Truncated again.
In article <4ak145$7t4@news.res.ray.com>, tringali@news.ed.ray.com (Scott Tringali) writes:
|>How do I create my own shared libraries? I am working with a large (30+)
|>number of applications that have many common libraries. These are created with
|>cc -c, then ar, and then linked into the final application with cc.
|>
|>Is there any way I can take these libraries, compile them to a .so, and save on
|>disk space and memory? I haven't found any references how to do this in the cc
|>or ld man pages.
|>
You didn't look hard enough. It is in the ld(1) manual page:
NAME
ld, uld - link editor and ucode link editor
SYNOPSIS
ld [ option ... ] file ...
uld [ option ... ] file ...
DESCRIPTION
The ld command invokes the DEC OSF/1 link editor which links extended coff
object files. The archive format understood by ld is the one created by
the archiver ar(1).
-shared
Produce a shared object. This includes creating all of the tables for
run-time linking and resolving references to other specified shared
objects. The object created may be used by the linker to make dynamic
executables.
-call_shared
Produce a dynamic executable. The object created may use shared
objects at run-time.
Here is a simple example. Note that LD_LIBRARY_PATH must be set to include
the directory with the shared library, or, the library must live in
/usr/shlib.
scratch> cat Makefile
all: sharedapp
sharedapp: main.o shlib.so
cc -call_shared -o sharedapp main.o shlib.so
main.o: main.c
cc -g -c main.c
shlib.so: shlib.o
ld -shared shlib.o -o shlib.so /usr/shlib/libc.so
shlib.o: shlib.c
cc -g -c shlib.c
clean:
rm -f sharedapp main.o shlib.so
scratch> cat main.c
#include <stdio.h>
void main()
{
void sharedRoutine(void);
printf("In the main program.\n");
sharedRoutine();
}
scratch> cat shlib.c
#include <stdio.h>
void sharedRoutine(void)
{
printf("In the shared routine in the shared library.\n");
}
scratch> make clean all
rm -f sharedapp main.o shlib.so
cc -g -c main.c
ld -shared shlib.o -o shlib.so /usr/shlib/libc.so
cc -call_shared -o sharedapp main.o shlib.so
scratch> (export LD_LIBRARY_PATH=.; ./sharedapp)
In the main program.
In the shared routine in the shared library.
scratch> (export LD_LIBRARY_PATH=.; ladebug ./sharedapp)
Welcome to the Ladebug Debugger Version 4.0-10
------------------
object file name: ./sharedapp
Reading symbolic information ...done
(ladebug) listobj
listobj
ObjectName Start Addr Size Symbols
(bytes) Loaded
----------------------------------------------------------------------------
/sharedapp 0x120000000 8192 Yes
/shlib.so 0x3ffbfff0000 8192 Yes
/usr/shlib/libc.so 0x3ff80800000 901120 Yes
(ladebug) quit
quit
scratch>
Good luck,
Tim
--
Timothy J. Lucia Email: mailto:lucia@zko.dec.com
Digital Equipment Corporation Phone: 603.881.2615
110 Spitbrook Road ZKO2-3/K06 Fax: 603.881.0120
Nashua, NH USA 03062-2698 I'd rather be cycling.
^ permalink raw reply [flat|nested] 8+ messages in thread
* Creating Shared Libraries
@ 1997-02-07 5:00 Christopher Yap
1997-02-08 5:00 ` Graham Jones
1997-02-12 5:00 ` Tim Lucia
0 siblings, 2 replies; 8+ messages in thread
From: Christopher Yap @ 1997-02-07 5:00 UTC (permalink / raw)
I am compiling a library on our OSF machine running V3.2.
I am using gcc 2.7.2.1.
I would like to create a shared library, but do not know what the proper
command line is to do this. Can anyone help?
gcc -shared does not work.
Thanks in advance.
--
Christopher Yap
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: Creating Shared Libraries
1997-02-07 5:00 Creating Shared Libraries Christopher Yap
@ 1997-02-08 5:00 ` Graham Jones
1997-02-12 5:00 ` Tim Lucia
1 sibling, 0 replies; 8+ messages in thread
From: Graham Jones @ 1997-02-08 5:00 UTC (permalink / raw)
Christopher Yap <cyap@monet.esys.ca> wrote in article
<5dfpaa$k22@missun.cus.cul.ca>...
> I would like to create a shared library, but do not know what the proper
> command line is to do this.
something like this:
gcc -c module.c
ld -shared -noarchive module.o -o module.so -lc
It's ld that you use to create the shared library.
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: Creating Shared Libraries
1997-02-07 5:00 Creating Shared Libraries Christopher Yap
1997-02-08 5:00 ` Graham Jones
@ 1997-02-12 5:00 ` Tim Lucia
1 sibling, 0 replies; 8+ messages in thread
From: Tim Lucia @ 1997-02-12 5:00 UTC (permalink / raw)
To: Christopher Yap
Makefile:
#
# Simple example of how to build a shared library on Digital UNIX(tm).
# Written by: Timothy J. Lucia, lucia@zko.dec.com
#
# Don't forget to set LD_LIBRARY_PATH to the cwd (.) before running
# the main program. In the K-shell, this is done via:
#
# $ export LD_LIBRARY_PATH=.
#
# and in the C-shell:
#
# % setenv LD_LIBRARY_PATH .
#
DEBUGFLAGS = -g -O0
CCFLAGS = $(DEBUGFLAGS)
CC = cc $(CCFLAGS)
LDFLAGS = $(DEBUGFLAGS)
LD = ld $(LDFLAGS)
RM = rm -f
all: main library.so
main: main.o library.so
$(CC) -o main main.o library.so
main.o: main.c
$(CC) -c main.c
library.so: library.o
$(LD) -shared -o library.so library.o -lc
library.o: library.c
$(CC) -c library.c
clean:
$(RM) main main.o library.o library.so so_locations
library.c:
#include <stdio.h>
void bar(void)
{
printf("Inside shared library:bar()\n");
}
main.c:
#include <stdio.h>
void main(void)
{
extern void bar(void);
printf("Inside of main\n");
bar();
}
~/example> make CC=gcc
gcc -c main.c
gcc -c library.c
ld -g -O0 -shared -o library.so library.o -lc
gcc -o main main.o library.so
~/example> ./main
Inside of main
Inside shared library:bar()
~/example>
Enjoy!
Tim
--
Timothy J. Lucia Digital Ladebug Debugger Developer
Digital Equipment Corporation Cat IV Charter/Banyan/Wheelworks/NEBC
110 Spitbrook Road ZK2-3Q08 Email: lucia@zko.dec.com
Nashua, NH USA 03062-2698 603.881.2615(Voice)/603.881.0120(FAX)
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~1997-02-12 5:00 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
1995-12-12 5:00 Creating shared libraries Scott Tringali
1995-12-13 5:00 ` Jochen Klein
1995-12-15 5:00 ` Tim Lucia
1995-12-18 5:00 ` Tim Lucia
1995-12-18 5:00 ` Tim Lucia
-- strict thread matches above, loose matches on Subject: below --
1997-02-07 5:00 Creating Shared Libraries Christopher Yap
1997-02-08 5:00 ` Graham Jones
1997-02-12 5:00 ` Tim Lucia
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox