* RE: Creating static libraries using gcc
@ 2002-03-19 1:44 Thai Dang Vu
2002-03-19 2:50 ` bjorn rohde jensen
0 siblings, 1 reply; 3+ messages in thread
From: Thai Dang Vu @ 2002-03-19 1:44 UTC (permalink / raw)
To: gcc-help
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
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: Creating static libraries using gcc
2002-03-19 1:44 Creating static libraries using gcc Thai Dang Vu
@ 2002-03-19 2:50 ` bjorn rohde jensen
0 siblings, 0 replies; 3+ messages in thread
From: bjorn rohde jensen @ 2002-03-19 2:50 UTC (permalink / raw)
To: gcc-help
Hi guys,
> 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?
>
Right, this is pretty much the standard way to build shared libraries
on linux and other unix flavors. The choice of compiler and options
needed does vary a bit. To build a shared library with more than 1
.o file, you simply list more than 1, it is that simple.
g++ -shared -o libshared.so *.o
> When I have a new file, is that right if I do
>
> g++ newfile.cpp libshared.so?
>
Maybe, i think, you can link with a shared library like that. I prefer
putting the libraries in a lib directory somewhere,so they don't clutter
my working directory, and use
g++ -o main -L/somepath/lib -lshared main.cpp
Yours sincerely,
Bjorn
^ permalink raw reply [flat|nested] 3+ messages in thread
* Creating static libraries using gcc
@ 2002-03-19 1:03 Scott Sinclair
0 siblings, 0 replies; 3+ messages in thread
From: Scott Sinclair @ 2002-03-19 1:03 UTC (permalink / raw)
To: gcc-help
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
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2002-03-19 10:50 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-03-19 1:44 Creating static libraries using gcc Thai Dang Vu
2002-03-19 2:50 ` bjorn rohde jensen
-- strict thread matches above, loose matches on Subject: below --
2002-03-19 1:03 Scott Sinclair
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).