Building shared libraries on Solaris 2.5.1

Martin Kahlert martin.kahlert@keksy.mchp.siemens.de
Fri Oct 1 00:00:00 GMT 1999


[Posted and mailed]

In article <Pine.GSO.3.96.990907145701.17858B-100000@xenon.stanford.edu>,
	Trevor Gattis <trevor@cs.stanford.edu> writes:
> 
> Does anyone know the correct way to build a shared object from a simple
> header file containing one function call prototype and a .c file that
> defines the function itself?

I hope, your .c file includes your .h file.
Then do this:
gcc -fPIC -c prog.c
gcc -shared -o libprog.so prog.o -lc
(You can put in a soname, too)

To link another prog with your lib:
gcc -o newprog newprog.c -L. -lprog
To execute newprog, you should add the path of the shared lib to
the LD_LIBRARY_PATH environment variable:
setenv LD_LIBRARY_PATH ${LD_LIBRARY_PATH}:.
or 
export LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:.
or something similar your shell understands.

Hope that helps,
Martin.


-- 
esa$ gcc -Wall -o ariane5 ariane5.c
ariane5.c: 666: warning: long float implicitly truncated to unsigned type
esa$ ariane5


More information about the Gcc-help mailing list