building a library file from other libraries?

building a library file from other libraries?

Post by Mike Web » Tue, 05 Nov 1996 04:00:00



Hi all,

I'm working on a project which is essentially developing an API to sit
on top of our current code base; when I'm done I'll have a single
libwhatever.a file and whatever.h header file, so all that people will
have to do is include the header file and link to the library, and
presto, they can use the code through the API.  Simple enough.

The problem I'm having is that the code I want to use resides in a
handful of different library files; I'd really like to just deliver one
library, and additionally, I'd like only the symbols defined in the API
to be visible (via nm or what-have-you) and none of the internal
functions should be visible.

To be a little more detailed: I've got around 6 .a files, and a single
.cpp and .h file which define the API.  The .a files were created simply
by running "ar libwhatever.a file1.o file2.o ... " on Linux-elf.

Thanks for any help and advice!
Mike Webb

 
 
 

building a library file from other libraries?

Post by Stephen Bayn » Wed, 06 Nov 1996 04:00:00


: Hi all,

: I'm working on a project which is essentially developing an API to sit
: on top of our current code base; when I'm done I'll have a single
: libwhatever.a file and whatever.h header file, so all that people will
: have to do is include the header file and link to the library, and
: presto, they can use the code through the API.  Simple enough.

: The problem I'm having is that the code I want to use resides in a
: handful of different library files; I'd really like to just deliver one
: library, and additionally, I'd like only the symbols defined in the API
: to be visible (via nm or what-have-you) and none of the internal
: functions should be visible.

: To be a little more detailed: I've got around 6 .a files, and a single
: .cpp and .h file which define the API.  The .a files were created simply
: by running "ar libwhatever.a file1.o file2.o ... " on Linux-elf.

Apart from the direct approach of extracting all the .o files and making a new
archive you could try the following (assuming that they are in the standard
UNIX archive format):

cp l1.a lall.a
tail -c+9 l2.a >> lall.a
tail -c+9 l3.a >> lall.a
tail -c+9 l4.a >> lall.a
tail -c+9 l5.a >> lall.a

The problem with this is that it may not handle the symbol table correctly.
This can be fixed by using ranlib if your system has it. You might be able
to persuade ar to do the same thing by then using it to add another object.

--

Philips Semiconductors Ltd                  
Southampton                                 +44 (01703) 316431
United Kingdom                              My views are my own.
 Are you using ISO8859-1? Do you see ? as copyright, as division and ? as 1/2?

 
 
 

building a library file from other libraries?

Post by David Thomas Richard Giv » Wed, 06 Nov 1996 04:00:00



[...]

Quote:>The problem I'm having is that the code I want to use resides in a
>handful of different library files; I'd really like to just deliver one
>library, and additionally, I'd like only the symbols defined in the API
>to be visible (via nm or what-have-you) and none of the internal
>functions should be visible.

>To be a little more detailed: I've got around 6 .a files, and a single
>.cpp and .h file which define the API.  The .a files were created simply
>by running "ar libwhatever.a file1.o file2.o ... " on Linux-elf.

[...]

Well, your first problem is easy enough:

        ar xv libfirst.a
        ar xv libsecond.a
        ...
        ar xv liblist.a
        ar rv liball.a *.o

Remember, a .a file is just an archive of lots of .o files. Like a tar
archive but without paths.

I can't help you with your second problem, I'm afraid, and would love to
know the answer myself. The single level of data hiding in Unix standard
object files is one of the things that annoys me. There's probably some
way of doing it but I have a * suspicion it involves doing hideous
things with ld. :(

--
------------------- http://www.veryComputer.com/~dg --------------------
   If you're up against someone more intelligent than you are, do something
    totally insane and let him think himself to death.  --- Pyanfar Chanur
---------------- Sun-Earther David Daton Given of Lochcarron ------------------

 
 
 

1. Building shared library which includes static libraries

SPARC Solaris 2.4 using 4.0.1 SPARC C++ compiler.

My application comprises of an executable and a number of shared libraries.
One of the shared libraries is an interface to Oracle using OCI calls. This
shared (database) library was built as follows:

    ld -G -dy -B symbolic -o my_shared_lib.so mod1.o mod2.o ... Oracle static
        libraries ... more libraries..

mod1.o, mod2.o ... were compiled with the -PIC option.

Now, when I run my application, I crash, with a bad opcode, whenever any
Oracle function is accessed from the mod1.o mod2.o ... modules. If I link the
Oracle static libraries with the executable, then everything is fine. However,
that is not what I want.

How can I get the above to work, or is it not possible? Any comments/advice
will be greatfully appreciated.

Thanks in advance,

Sanjay Agrawal
--

555 Twin Dolphin Drive #400      Voice: (415)594-8754
Redwood City, CA 94065           Fax:   (415)594-8645

2. Apache and ErrorDocument problem

3. How do I build a library with other libraries ?

4. Apache startup behavior: DocumentRoot

5. Building shared libraries that contain static libraries.

6. possible problem with message-nondiscard-mode in Solaris

7. Help with building shared libraries with dependencies on other shared libraries

8. Microsoft Re-writes history!

9. Using libtool to build shared libraries that depend on static libraries

10. libraries libraries libraries

11. link compat=4 built library with a compat=5 build code

12. Q: exp files and build shared-stl library in AIX

13. Export file for shared library build