473,378 Members | 1,621 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

Shared Library On Solaris 10 using g++ 3.4.3

Hello,

I am trying to create a shared library on solaris. The inputs to this
library is a source file and then 2 static libraries.

I need to call code within the shared library in another application
which in turn will use the static libraries for further processing.

This is the command i am using to build the shared library

g++ -Wno-deprecated -DSOLARIS -DSUN4 -DSUN -DSVR4 -
D_POSIX_PTHREAD_SEMANTICS
-I/usr/java/include -I/usr/java/include/solaris -I/home1/users/biyer/
Bala/OAPI/include
-I/home1/users/biyer/Bala/OAPI/src ../lib/liba ../lib/libb Common.C -o
Common.o

g++ -fpic -D_REENTRANT -shared Common.o -o libSubscribe.so

Though the file that i have included in Common.C has declaration for
the method ULIST_create that i am calling from Common.C, it still
gives me a compilation error
Undefined first referenced
symbol in file
ULIST_create() /var/tmp//ccxiLplo.o

I get similar errors for every method that i am trying to call from
Common.C which are defined in the static libraries.

Am I creating the shared library the way it should be created? Can you
please let me know where its going wrong?

Thanks in advance

Nov 8 '07 #1
3 3248
On Nov 13, 12:02 am, Bala <R.Balaji.I...@gmail.comwrote:
On Nov 9, 5:01 am, James Kanze <james.ka...@gmail.comwrote:
On Nov 8, 8:50 pm, Bala <R.Balaji.I...@gmail.comwrote:
[...]
I was able to create the shared libraries and run it properly. Thanx
for all the help. But i cant g o ahead with g++ because one of those
static libraries has been compiled with Sun studio CC 5.8. The mangled
names are too different and it gives me runtime errors while trying to
resolve those.
Not just the mangled names. The class layout is different as
well. The mangled names are intentionally different, because if
you could link, all you'd get is a core dump (or some other
strange behavior) at runtime.
I planned to move my application to CC instead but this is
giving me another strange problem.
Be very, very careful. The libraries (both alternatives)
available with CC are really bad.
I created a shared library using CC with the following command
CC -G -D_REENTRANT -DSOLARIS -DSUN4 -DSUN -DSVR4 -
D_POSIX_PTHREAD_SEMANTICS -I/usr/java/include -I/usr/java/include/
solaris -I/home1/users/biyer/Bala/OAPI/include -I/home1/users/biyer/
Bala/OAPI/src Common.cpp liba.a libb.b -o libSubscribe.so
Then i compiled my source as
CC -DSOLARIS -DSUN4 -DSUN -DSVR4 -D_POSIX_PTHREAD_SEMANTICS -I/home1/
users/biyer/Bala/OAPI/include -I/home1/users/biyer/Bala/OAPI/src
Main.cpp -o Main.o
Now when i run Main.o it says its not able to open the shared
library. It prints an error message which is part of my code.
"Error Loading the Dynamic Library"
This is really getting off topic, but what does dlerr() say?

Just a hunch, however: you need a -ldl at the end of your link
line. Otherwise, you just get stubs for dlopen et al. (I'll
admit that I don't understand this. By default, the system
libraries are loaded dynamically, so the guts of libdl must be
there, even if you don't specify it.)

Maybe the g++ driver adds this automatically. (I have it in my
Linux builds with g++, however. I don't know if it's necessary,
however. I know I needed it once, and I probably just threw it
in everywhere.)

--
James Kanze (GABI Software) email:ja*********@gmail.com
Conseils en informatique orientée objet/
Beratung in objektorientierter Datenverarbeitung
9 place Sémard, 78210 St.-Cyr-l'École, France, +33 (0)1 30 23 00 34

Nov 13 '07 #2
On Nov 13, 4:56 am, James Kanze <james.ka...@gmail.comwrote:
On Nov 13, 12:02 am, Bala <R.Balaji.I...@gmail.comwrote:
On Nov 9, 5:01 am, James Kanze <james.ka...@gmail.comwrote:
On Nov 8, 8:50 pm, Bala <R.Balaji.I...@gmail.comwrote:

[...]
I was able to create the shared libraries and run it properly. Thanx
for all the help. But i cant g o ahead with g++ because one of those
static libraries has been compiled with Sun studio CC 5.8. The mangled
names are too different and it gives me runtime errors while trying to
resolve those.

Not just the mangled names. The class layout is different as
well. The mangled names are intentionally different, because if
you could link, all you'd get is a core dump (or some other
strange behavior) at runtime.
I planned to move my application to CC instead but this is
giving me another strange problem.

Be very, very careful. The libraries (both alternatives)
available with CC are really bad.
I created a shared library using CC with the following command
CC -G -D_REENTRANT -DSOLARIS -DSUN4 -DSUN -DSVR4 -
D_POSIX_PTHREAD_SEMANTICS -I/usr/java/include -I/usr/java/include/
solaris -I/home1/users/biyer/Bala/OAPI/include -I/home1/users/biyer/
Bala/OAPI/src Common.cpp liba.a libb.b -o libSubscribe.so
Then i compiled my source as
CC -DSOLARIS -DSUN4 -DSUN -DSVR4 -D_POSIX_PTHREAD_SEMANTICS -I/home1/
users/biyer/Bala/OAPI/include -I/home1/users/biyer/Bala/OAPI/src
Main.cpp -o Main.o
Now when i run Main.o it says its not able to open the shared
library. It prints an error message which is part of my code.
"Error Loading the Dynamic Library"

This is really getting off topic, but what does dlerr() say?

Just a hunch, however: you need a -ldl at the end of your link
line. Otherwise, you just get stubs for dlopen et al. (I'll
admit that I don't understand this. By default, the system
libraries are loaded dynamically, so the guts of libdl must be
there, even if you don't specify it.)

Maybe the g++ driver adds this automatically. (I have it in my
Linux builds with g++, however. I don't know if it's necessary,
however. I know I needed it once, and I probably just threw it
in everywhere.)

--
James Kanze (GABI Software) email:james.ka...@gmail.com
Conseils en informatique orientée objet/
Beratung in objektorientierter Datenverarbeitung
9 place Sémard, 78210 St.-Cyr-l'École, France, +33 (0)1 30 23 00 34
Haha. I tried that already but doesnt seem to work. I looked at
dlerror() and it says it couldnt find a referenced symbol. the name
of the symbol is mangled. And since the static libraries that i am
using are external, i dont have the source code to find out where and
how its declared. I just linked the static libraries while creating
the shared library using the above command. Not sure though which way
to go ahead :)

Nov 13 '07 #3
On Nov 13, 7:33 pm, Bala <R.Balaji.I...@gmail.comwrote:
On Nov 13, 4:56 am, James Kanze <james.ka...@gmail.comwrote:
On Nov 13, 12:02 am, Bala <R.Balaji.I...@gmail.comwrote:
On Nov 9, 5:01 am, James Kanze <james.ka...@gmail.comwrote:
On Nov 8, 8:50 pm, Bala <R.Balaji.I...@gmail.comwrote:
[...]
This is really getting off topic, but what does dlerr() say?
[...]
Haha. I tried that already but doesnt seem to work. I looked at
dlerror() and it says it couldnt find a referenced symbol.
After dlopen()?
the name of the symbol is mangled. And since the static
libraries that i am using are external, i dont have the source
code to find out where and how its declared.
nm libxxx.so | egrep symbol

can be useful in such cases. There is also c++filt, to
demangle. You might try demangling, and greping for the
demangled name in the libs. Just in case the symbol is actually
in C code, but the declaration you pulled in didn't have the
``extern "C"'' linkage specification.

Another possibility is that the library was compiled with a
different compiler, and so mangles differently. (Sun CC
supports at least two different conventions: see the -compat=4
option. Or one of the libraries was compiled with g++; this
would explain why there was no problem with g++.)
I just linked the static libraries while creating the shared
library using the above command. Not sure though which way to
go ahead :)
It sounds like you're in the Unix version of DLL-hell:-). The
worst thing about it is that if you get it to work on your
platform, it still might not work when deployed, because one of
the shared objects it depends on doesn't have the same version.
In my experience, you should make very, very sparing use of
shared objects, limiting their use to cases where it actually
has some necessary advantage.

--
James Kanze (GABI Software) email:ja*********@gmail.com
Conseils en informatique orientée objet/
Beratung in objektorientierter Datenverarbeitung
9 place Sémard, 78210 St.-Cyr-l'École, France, +33 (0)1 30 23 00 34
Nov 14 '07 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Simon | last post by:
Hello. I wanna use my dynamic shared library(built with C language) with php script. (PHP version is 4.0.6) So I making a shared library(*.so) in Solaris environment(2.7) and it is successful....
0
by: Phil | last post by:
I realize this is the php group, but I have a question that recurses back to my php install. My objective is a pure 64 bit shared object installation of php 5.0 on UltraSparc Solaris 9 compiled...
0
by: Naresh Agarwal | last post by:
Hi I have written a Java program, which uses JNI to talk to native C code. The java program is working well on windows, Solaris, HP-UX and Linux but it fails on AIX. On AIX (version...
1
by: amit | last post by:
Hi, I have got GNU c++ compiler installed on solaris.I want to create a shared object library on solaris for an External stored procedure.Got makefil.sol to be used on solaris as under : CC=CC...
5
by: Oliver | last post by:
Hi, I have a problem with a shared library of mine. I compile the *.o files and then generate the .so lib with: cc -shared libjava_vrpn.so *.o When I then run my program I get an error for an...
6
by: klh | last post by:
I have an old version of DB2 Connect (v 6) installed on a Sun Solaris (v 2.9)box. It has been installed for several years, and to me, it seems to work okay. However, an application that uses DB2...
3
by: djbaker | last post by:
Greetings, I am trying to create a class library/dll with C++ and I am running into a lot of trouble. I know that this is a C++ forum and not one specific to windows or VS 2005 but I'm hoping...
0
by: sebor | last post by:
October 29, 2007 -- The Apache C++ Standard Library project is pleased to announce that the official stdcxx 4.2.0 release is now available for download from the following location:...
1
by: JNLSeb | last post by:
When on Solaris, if a shared library (libmylib.so) is built using the gcc compiler and Application 1 is built using a general C (cc) compiler but links in the newly built library (libmylib.so)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.