public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
From: Oscar Fuentes <ofv@wanadoo.es>
To: gcc-help@gcc.gnu.org
Cc: long21st@yahoo.com
Subject: Re: How to build a static library using another one?
Date: Thu, 25 Jul 2002 18:40:00 -0000	[thread overview]
Message-ID: <fzy75l09.fsf@wanadoo.es> (raw)
In-Reply-To: <20020726002838.17223.qmail@web14405.mail.yahoo.com>

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


      reply	other threads:[~2002-07-26  1:40 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-07-25 17:28 Long Li
2002-07-25 18:40 ` Oscar Fuentes [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=fzy75l09.fsf@wanadoo.es \
    --to=ofv@wanadoo.es \
    --cc=gcc-help@gcc.gnu.org \
    --cc=long21st@yahoo.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).