public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
* How to build a static library using another one?
@ 2002-07-25 17:28 Long Li
  2002-07-25 18:40 ` Oscar Fuentes
  0 siblings, 1 reply; 2+ messages in thread
From: Long Li @ 2002-07-25 17:28 UTC (permalink / raw)
  To: gcc-help

Hi, Guys,

I am a newbie on making library in C & C++. I have
some c++ souce code files(a.cpp, b.cpp) and a C++
library(libutil.a) at hand. The c++ source code
files(a.cpp, b.cpp) use the functions of library
libtuil.a. I would like to build a single library
using them. This is what I tried:

I first compiled the source code files. Then I use

ar rc libcpp.a a.o b.o libutil.a
ranlib libcpp.a

It works fine. However, later when I used this library
in my other souce files, I got some compile error. It
seems the compiler found some undefined symbols in a.o
and b.o, those symbols happen to be the functions in
libtutil.a. 

Could you tell me how to make it work?

Thanks a lot!


Long 

__________________________________________________
Do You Yahoo!?
Yahoo! Health - Feel better, live better
http://health.yahoo.com

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: How to build a static library using another one?
  2002-07-25 17:28 How to build a static library using another one? Long Li
@ 2002-07-25 18:40 ` Oscar Fuentes
  0 siblings, 0 replies; 2+ messages in thread
From: Oscar Fuentes @ 2002-07-25 18:40 UTC (permalink / raw)
  To: gcc-help; +Cc: long21st

Long Li <long21st@yahoo.com> writes:

> Hi, Guys,
> 
> I am a newbie on making library in C & C++. I have
> some c++ souce code files(a.cpp, b.cpp) and a C++
> library(libutil.a) at hand. The c++ source code
> files(a.cpp, b.cpp) use the functions of library
> libtuil.a. I would like to build a single library
> using them. This is what I tried:
> 
> I first compiled the source code files. Then I use
> 
> ar rc libcpp.a a.o b.o libutil.a
> ranlib libcpp.a
> 
> It works fine. However, later when I used this library
> in my other souce files, I got some compile error. It
> seems the compiler found some undefined symbols in a.o
> and b.o, those symbols happen to be the functions in
> libtutil.a. 
> 
> Could you tell me how to make it work?

Try this:

move libutil.a, a.o and b.o to an empty directory.

On that directory do:

ar x libutil.a

ar rc libcpp.a *.o
ranlib libcpp.a

See if libcpp.a works for you. If it doesn't, try creating a dummy
executable that uses a.o, b.o and libutil.a. If it still complains
about undefined symbols, maybe the problem is in your object files,
not on the procedure for building the library.

-- 
Oscar


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2002-07-26  1:40 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-07-25 17:28 How to build a static library using another one? Long Li
2002-07-25 18:40 ` Oscar Fuentes

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).