Unix Programming - AIX and dlopen

This is Interesting: Free IT Magazines  
Home > Archive > Unix Programming > March 2004 > AIX and dlopen





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 AIX and dlopen
gailw

2004-03-17, 5:37 pm

AIX archives it's shared libraries into .a files. E.g. libmqm_r.a contains
libmqm_r.o where libmqm_r.o is a shared library (well, I think it's a shared
library). I extracted it and "file" tells me
libmqm_r.o "executable (RISC System/6000) or object module not stripped".

If I want to a dlopen of one of these shared libraries, do I have to first
extract the shared library from the archive file. I tried dlopen of both
libmqm_r.a and libmqm_r.o and neither works.

Why did IBM do it so weird?

Thanks,

Jim




David Schwartz

2004-03-17, 5:37 pm


"gailw" <gailw@worldnet.att.net> wrote in message
news:4E36c.26946$Pa7.690366@bgtnsc05-news.ops.worldnet.att.net...


> AIX archives it's shared libraries into .a files. E.g. libmqm_r.a
> contains
> libmqm_r.o where libmqm_r.o is a shared library (well, I think it's a
> shared
> library). I extracted it and "file" tells me
> libmqm_r.o "executable (RISC System/6000) or object module not
> stripped".



I don't think those are shared libraries. They look like static
libraries.


> If I want to a dlopen of one of these shared libraries, do I have to first
> extract the shared library from the archive file. I tried dlopen of both
> libmqm_r.a and libmqm_r.o and neither works.



You probably have to link them into a shared library with something like
'ld -shared'.

DS



joe@invalid.address

2004-03-17, 9:37 pm

"gailw" <gailw@worldnet.att.net> writes:

> AIX archives it's shared libraries into .a files. E.g. libmqm_r.a
> contains libmqm_r.o where libmqm_r.o is a shared library (well, I
> think it's a shared library). I extracted it and "file" tells me
> libmqm_r.o "executable (RISC System/6000) or object module not
> stripped".
>
> If I want to a dlopen of one of these shared libraries, do I have to
> first extract the shared library from the archive file. I tried
> dlopen of both libmqm_r.a and libmqm_r.o and neither works.


There isn't a special extension for shared libraries in AIX. They use
an extended form of COFF which doesn't need it (and therefore isn't
really "Common" anymore :-).

There used to be a very good reference on the web about this but I
can't find it now, and I don't remember all the details
precisely. However, if you build a shared library according to the man
page you should be able to dlopen() it in recent versions of
AIX. There's some distinction I can't recall at the moment about .o
files that are built to be dynamically loaded (and I can't find the
link any more) but maybe someone else here can help.

Try looking around on IBM's redbook web site. It's probably there
somplace.

> Why did IBM do it so weird?


Many times we think things are weird because we didn't design them :-)

Joe
--
Don't worry, be happy
- Bobby McFerrin
joe@invalid.address

2004-03-17, 9:37 pm

joe@invalid.address writes:

> "gailw" <gailw@worldnet.att.net> writes:
>
>
> There isn't a special extension for shared libraries in AIX. They use
> an extended form of COFF which doesn't need it (and therefore isn't
> really "Common" anymore :-).
>
> There used to be a very good reference on the web about this but I
> can't find it now, and I don't remember all the details
> precisely. However, if you build a shared library according to the man
> page you should be able to dlopen() it in recent versions of
> AIX. There's some distinction I can't recall at the moment about .o
> files that are built to be dynamically loaded (and I can't find the
> link any more) but maybe someone else here can help.


I found an internal (ie, local to my disk) reference which says that
you need to build a .o version of a library for dynamic loading, so
that's probably the distinction. It's been a coupld years since I've
done any programming on AIX though and I'm a little fuzzy on the
details so I don't want to be very specific.

The best advice I have is to read the ld man page. Maybe search the
web looking for an AIX library reference, although it looks to me like
they've purged them all (all my bookmarks are dead now).

Joe
--
Don't worry, be happy
- Bobby McFerrin
gailw

2004-03-17, 9:37 pm

Actually, I extracted the libmqm_r.o file from the libmqm_r.a archive and I
was able to load it with dlopen and find a symbol with dlsym; so I think
it's a loadable shared library.

--

Gail

"David Schwartz" <davids@webmaster.com> wrote in message
news:c3ajiu$864$1@nntp.webmaster.com...
>
> "gailw" <gailw@worldnet.att.net> wrote in message
> news:4E36c.26946$Pa7.690366@bgtnsc05-news.ops.worldnet.att.net...
>
>
>
>
> I don't think those are shared libraries. They look like static
> libraries.
>
>
first[color=darkred]
both[color=darkred]
>
>
> You probably have to link them into a shared library with something

like
> 'ld -shared'.
>
> DS
>
>
>



Chuck Dillon

2004-03-18, 9:46 am

gailw wrote:
> AIX archives it's shared libraries into .a files. E.g. libmqm_r.a contains
> libmqm_r.o where libmqm_r.o is a shared library (well, I think it's a shared
> library). I extracted it and "file" tells me
> libmqm_r.o "executable (RISC System/6000) or object module not stripped".
>
> If I want to a dlopen of one of these shared libraries, do I have to first
> extract the shared library from the archive file. I tried dlopen of both
> libmqm_r.a and libmqm_r.o and neither works.
>
> Why did IBM do it so weird?
>
> Thanks,
>
> Jim
>
>
>
>


Some more stale memory based advice on AIX shared libraries. As I
recall by default the symbols are not exported like on other *nix
systems. The best resource I found was a white paper I found on a
developer's site, something linke bolder.ibm.com or some such.

Did you ask in comp.unix.aix?

-- ced

--
Chuck Dillon
Senior Software Engineer
NimbleGen Systems Inc.

Bjorn Reese

2004-03-18, 3:35 pm

On Wed, 17 Mar 2004 14:30:54 -0800, David Schwartz wrote:

> I don't think those are shared libraries. They look like static
> libraries.


An oddity about AIX is that shared libraries use the .a extension
(all code is position independent in the first place.)

--
mail1dotstofanetdotdk

gailw

2004-03-19, 11:36 am

Here is a post from comp.unix.aix.
I had already found the info about dlopen from a search of IBM site, but
this post provides a good reference - probably the one someone else
mentioned in this thread.
"gailw" <gailw@worldnet.att.net> writes:

> If I want to a dlopen of one of these shared libraries, do I have to first
> extract the shared library from the archive file.


No.

> I tried dlopen of both libmqm_r.a and libmqm_r.o and neither works.


Because neither is correct. You need:

dlopen("libmqm_r.a(libmqm_r.o)", RTLD_MEMBER);

> Why did IBM do it so weird?


Their shared libraries do not follow Solaris/SVR4 model.

The "weirdness" of the dlopen() only scratches the surface, there
are many more to come. If you are going to do any serious development
on AIX with shared libraries, begin by reading and understanding
this:

http://www-106.ibm.com/developerwor...pdfs/aix_ll.pdf

Cheers,
--
In order to understand recursion you must first understand recursion.
Remove /-nsp/ for email.


Sponsored Links






Free braindumps | Software forum | Database administration forum

Copyright 2003 - 2008 webservertalk.com