By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,413 Members | 999 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,413 IT Pros & Developers. It's quick & easy.

HPUX, shared library and static member variables

P: n/a
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
Share this Question
Share on Google+
1 Reply


P: n/a

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.