467,927 Members | 1,954 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 467,927 developers. It's quick & easy.

HPUX, shared library and static member variables

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_10Validators9CBaseCop y (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.
Jul 23 '05 #1
  • viewed: 2660
Share:
1 Reply

Torsten Mueller wrote:
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_10Validators9CBaseCop y (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-

Jul 23 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

18 posts views Thread by Peter Smithson | last post: by
5 posts views Thread by | last post: by
15 posts views Thread by Rob Nicholson | last post: by
1 post views Thread by Brian Henry | last post: by
8 posts views Thread by gemel | last post: by
11 posts views Thread by Mr Newbie | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.