|
Home > Archive > Unix Programming > February 2007 > Creating a static library with other libraries
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
Creating a static library with other libraries
|
|
| jose_luis_fdez_diaz 2007-02-21, 1:18 pm |
|
Hi,
Given these static libraries:
- libstatic1.a
- libstatic2.a
I link they with a the "main" file: main.c
aCC -lstatic1 -lstatic2 main.c
In libstatic1.a objects files I use classes declared in libstatic2.a.
When I link I get this error:
/usr/ccs/bin/ld: (Warning) The CTTI instantiation with key symbol
"LBXRecord::~LBXRecord()" in file main.o has been overridden by an
explicit definition in file lib/libstatic2.a. This behavior may not be
supported in future releases.
To fix this issue I appended libstatic2.a to libstatic1.a when I
created it:
ar libstatic1.a libstatic1.a *.o
and link with:
aCC -lstatic1 main.c
But I have global vars defined in some libstatic2.a objects files so
the objects files in libstatci1.a don't see them so the linker give "/
usr/ccs/bin/ld: Unsatisfied symbols"
If I extract the libstatic2.a object files:
ar -x libstatic2.a -->> libstatic2.objs
and attach them to libstatic1.a
ar rv libstatic2.objs *.o
I fix this last issue.
Is there a way to do this without extract the libstatic2.a object
files?
Thanks in advance,
Jose Luis
| |
| Paul Pluzhnikov 2007-02-21, 7:16 pm |
| "jose_luis_fdez_diaz" <gfiuni2@gmail.com> writes:
> Given these static libraries:
>
> - libstatic1.a
> - libstatic2.a
>
> I link they with a the "main" file: main.c
>
> aCC -lstatic1 -lstatic2 main.c
This is a bogus command line. Use:
aCC main.c -lstatic1 -lstatic2
and read this:
http://webpages.charter.net/ppluzhnikov/linker.html
if you want to understand why your order of libraries and
sources/objects is wrong.
> /usr/ccs/bin/ld: (Warning) The CTTI instantiation with key symbol
> "LBXRecord::~LBXRecord()" in file main.o has been overridden by an
> explicit definition in file lib/libstatic2.a. This behavior may not be
> supported in future releases.
>
>
> To fix this issue I appended libstatic2.a to libstatic1.a when I
> created it:
>
> ar libstatic1.a libstatic1.a *.o
This is even more bogus:
- I doubt that is *acutal* command you used;
you probably did "ar libstatic1.a libstatic2.a *.o"
- besides, the linker will not search libstatic1.a recursively; it
will simply ignore anything in libstatic1.a which isn't an object
(and libstatic2.a is not an object; it's an archive).
> Is there a way to do this without extract the libstatic2.a object
> files?
Yes: use correct link line.
Cheers,
--
In order to understand recursion you must first understand recursion.
Remove /-nsp/ for email.
|
|
|
|
|