This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: dlopen() under AIX with gcc/g++


	I believe that libstdc++.a.2.10.0 is a static archive, given the
naming which I have seen (normally libstdc++.a is a symbolic link to that
static archive).  The standard AIX shared library is an archive of shared
objects, so using "file" is not very informative.  An archived object
named "shr.o" is a good sign.  One really needs to look at the archived
object using "dump -o" to see if the file header shared flag is set.

	First, depending on which version of "nm" you are using, you need
to include the "-C" flag.  AIX nm, demangles by default and "-C" turns off
demangling; GNU nm "-C" flag enables demangling -- exactly the opposite.
Without the appropriate flag some of the C++ functions will not be
exported.

	Second, why use "-brtl" linker flag?  That is intended for
System V-style shared objects created with the "-G" linker flag producing
a shared object with the standard GNU/Linux ".so" suffix.

	The following changes based on the above comments seem to work for
me.  Normally AIX shared objects are archived, but naming the shared
object with the ".a" archive suffix is perfectly okay, if confusing.
Archiving the shared object takes a little more effort to have dlopen()
access the correct shared object.

David


makai 107> make clean
rm -f *.o *.a *.exp ctest test *~
makai 108> make ctest
gcc -g -c -o test_c.o test_c.c
gcc -g -c -o mylib_c.o mylib_c.c
nm -Bpg mylib_c.o | awk -f expme.awk > libmylib_c.exp
gcc -shared -Wl,-bE:libmylib_c.exp -o libmylib_c.a mylib_c.o
gcc -o ctest test_c.o
makai 109> ./ctest
message is "This is the main program.
"
Opening the library libmylib_c.a
Opened the library libmylib_c.a
dlopen() returned 2
dlerror() returns 
0
Getting symbol getpoint from libmylib_c.a
dlsym() returned 536941756
Are we calling getpoint yet?
message is "This is the library message.."
makai 110> make test
g++ -g -c -o test.o test.cpp
g++ -g -c -o mylib.o mylib.cpp
nm -BCpg mylib.o | awk -f expme.awk > libmylib.exp
g++ -shared  -Wl,-bE:libmylib.exp -o libmylib.a mylib.o
g++ -o test test.o
makai 111> ./test
message is "This is the main program.
"
Opening the library libmylib.a
Opened the library libmylib.a
dlopen() returned 2
dlerror() returns 
0
Getting symbol getpoint from libmylib.a
dlsym() returned 536952844
Are we calling getpoint yet?
message is "This is the library message.."



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]