This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

RE: Creating static libraries using gcc



Compile all of your C++ source files to object file (file.o). Thenput
them in a library with

ar cr libraryfile.a file1.o file2.o

When you have a new file, say filenew.cpp, you can compile and link it
with

g++ filenew.cpp libraryfile.a

By the way, I dont know how to create shared library in Linux. this is
what i've heard about it, but i don't know if it works.

g++ -fPIC -c file1.cpp
g++ -fPIC -c file2.cpp

g++ -shared -o libshared.so file1.o
how can I put file2.o in libshared.so?

When I have a new file, is that right if I do

g++ newfile.cpp libshared.so?

Regards.

-----Original Message-----
From: Scott Sinclair [mailto:scott.sinclair@umgeni.co.za]
Sent: Tuesday, March 19, 2002 4:06 PM
To: gcc-help@gcc.gnu.org
Subject: Creating static libraries using gcc


Hi

I have a large number of related C++ source files which I want to
combine
into a static library using gcc 2.95.3-5 with cygwin. Could anyone tell
me
which linker options I need to specify to accomplish this ? I have tried
to
link the object files using the -shared switch (although I suspect this
produces something similar to a Windows dll ?) and the object code links
cleanly. 

However, when I try to build an executable which requires linking with
my
library I get the following error--
	collect2:ld terminated with signal 11 [Segmentation fault]

Any help will be appreciated as I can't seem to find anything useful in
the
documentation yet.

Thanks
Scott



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]