I want to build a library rather than an executable

Adam Stein adam@scan.mc.xerox.com
Wed Oct 20 12:32:00 GMT 2004


>I am currently porting an existing application from Solaris 2.6 to Solaris
>2.9 and switching to the GNU compiler 3.4.1 as well!! (previously used the
>Sun compiler)

To create a shared library, I do something like:

	ld -G -o mylib.so obj1.o obj2.o
	
For a static library, I do something like:

	ar cr mylib.a `lorder obj1.o obj2.o | tsort`
	
You can replace the names with variables in a Makefile as you would with 
anything else.  These lines are the ones that create the final library file.  
You, of course, have to compile your C++ files into object files as normal (i.e. 
g++ -c -o obj1.o obj1.cpp).

Hope this helps.

                                                Adam Stein
--
Adam Stein @ Xerox Corporation       Email: adam@scan.mc.xerox.com
                                            
Disclaimer: All views expressed             
here have been proved to be my own.  [http://www.csh.rit.edu/~adam/]



More information about the Gcc-help mailing list