HPUX, shared library and static member variables

T

Torsten Mueller

I have to create a shared library containing C++ classes with static
member variables on HPUX with aCC. I can compile and link the library
and a test application but when I start the program I get errors like
these:

/usr/lib/dld.sl: Unresolved symbol: namespaces (data) from /beda/lib/libLogicalValidation.sl
/usr/lib/dld.sl: Unresolved symbol: m_mapFielTypeIDsUBSHaben__Q2_10Validators9CBaseCopy (data) from /beda/lib/libLogicalValidation.sl
/usr/lib/dld.sl: Unresolved symbol: m_mapFielTypeIDsPFHaben__Q2_10Validators9CBaseCopy (data) from /beda/lib/libLogicalValidation.sl
/usr/lib/dld.sl: Unresolved symbol: typeid__XTQ2_10Validators9CBaseCopy_ (data) from /beda/lib/libLogicalValidation.sl
/usr/lib/dld.sl: Unresolved symbol: m_mapFielTypeIDsUBSSoll__Q2_10Validators9CBaseCopy (data) from /beda/lib/libLogicalValidation.sl
/usr/lib/dld.sl: Unresolved symbol: m_mapFielTypeIDsPFSoll__Q2_10Validators9CBaseCopy (data) from /beda/lib/libLogicalValidation.sl
/usr/lib/dld.sl: Unresolved symbol: typeid__XTQ2_10Validators21CUBSKtoSplitValidator_ (data) from /beda/lib/libLogicalValidation.sl

All these unresolved symbols are private static member variables. I
think their instances (sure they have instances) are not exported from
the shared library.

I compile my source files using the following command line:

aCC -g0 +Z -I ... -c -o ... $<

-g0 produces debugger information, +Z makes position independent code,
-I, -c and -o are as usual. I link the shared library using this:

aCC -g0 -b -n -L ... -l ... -o ... $(OBJ)

The aCC man page says:
-----------------------------------------------------------------
-b Cause the linker ld(1) to create a shared library
rather than a normal executable file. Object files
processed with this option must contain position
independent code (PIC). For details see ld(1), HP-UX
Linker and Libraries Online User's Guide and the
Programming on HP-UX manual.

-n Cause the output file from the linker to be marked as
shareable. For details and system defaults, see ld(1).
-----------------------------------------------------------------

Do I have to use any other specific compiler switch to export static
variables? Or do I have to use a specific construction in my code? Did
anybody have this problem?

T.M.
 
S

Shezan Baig

Torsten said:
I have to create a shared library containing C++ classes with static
member variables on HPUX with aCC. I can compile and link the library
and a test application but when I start the program I get errors like
these:

/usr/lib/dld.sl: Unresolved symbol: namespaces (data) from /beda/lib/libLogicalValidation.sl
/usr/lib/dld.sl: Unresolved symbol:
m_mapFielTypeIDsUBSHaben__Q2_10Validators9CBaseCopy (data) from
/beda/lib/libLogicalValidation.sl
/usr/lib/dld.sl: Unresolved symbol:
m_mapFielTypeIDsPFHaben__Q2_10Validators9CBaseCopy (data) from
/beda/lib/libLogicalValidation.sl
/usr/lib/dld.sl: Unresolved symbol:
typeid__XTQ2_10Validators9CBaseCopy_ (data) from
/beda/lib/libLogicalValidation.sl
/usr/lib/dld.sl: Unresolved symbol:
m_mapFielTypeIDsUBSSoll__Q2_10Validators9CBaseCopy (data) from
/beda/lib/libLogicalValidation.sl
/usr/lib/dld.sl: Unresolved symbol:
m_mapFielTypeIDsPFSoll__Q2_10Validators9CBaseCopy (data) from
/beda/lib/libLogicalValidation.sl
/usr/lib/dld.sl: Unresolved symbol:
typeid__XTQ2_10Validators21CUBSKtoSplitValidator_ (data) from
/beda/lib/libLogicalValidation.sl
All these unresolved symbols are private static member variables. I
think their instances (sure they have instances) are not exported from
the shared library.

I compile my source files using the following command line:

aCC -g0 +Z -I ... -c -o ... $<

-g0 produces debugger information, +Z makes position independent code,
-I, -c and -o are as usual. I link the shared library using this:

aCC -g0 -b -n -L ... -l ... -o ... $(OBJ)

The aCC man page says:
-----------------------------------------------------------------
-b Cause the linker ld(1) to create a shared library
rather than a normal executable file. Object files
processed with this option must contain position
independent code (PIC). For details see ld(1), HP-UX
Linker and Libraries Online User's Guide and the
Programming on HP-UX manual.

-n Cause the output file from the linker to be marked as
shareable. For details and system defaults, see ld(1).
-----------------------------------------------------------------

Do I have to use any other specific compiler switch to export static
variables? Or do I have to use a specific construction in my code? Did
anybody have this problem?

T.M.

Did you define those static member variables? For example:

Foo.h
-----

class Foo { static int bar; };

Foo.cpp
-------

int Foo::bar = 0; // <-- you must define the static variable in your
cpp file


Hope this helps,
-shez-
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,904
Latest member
HealthyVisionsCBDPrice

Latest Threads

Top