1752783 Members
5847 Online
108789 Solutions
New Discussion юеВ

Re: g++ linking issue

 
SOLVED
Go to solution
Jens Rehsack
Occasional Advisor

g++ linking issue

I'm currently setting up an snmp++/agent++ based snmpd for a client who's using gcc/g++ to compile software.

I added some autoconf-stub to snmp++ and compiled it on all taget platforms. All HP-UX 11.x/hppa failed with the same issue. Short log:

g++ -g -O2 -D_REENTRANT -pthread -o .libs/snmpGet snmpGet.o
-L/sysmgmt/opt/openssl/lib -L../src/.libs -lsnmp++
-L/var/bintmp/gcc-4.2.3/gccobj/hppa2.0w-hp-hpux11.23/libstdc++-v3/src
-L/var/bintmp/gcc-4.2.3/gccobj/hppa2.0w-hp-hpux11.23/libstdc++-v3/src/.libs
-L/var/bintmp/gcc-4.2.3/gccobj/./gcc
-L/usr/local/hppa2.0w-hp-hpux11.23/bin -L/usr/local/lib -lstdc++
-L/usr/local/lib/gcc/hppa2.0w-hp-hpux11.23/4.2.3 -L/usr/ccs/lib
-L/opt/langtools/lib -lm -lgcc -lssl -lcrypto -pthread -Wl,+b
-Wl,/var/tmp/build_0.797255175977142/src/.libs:/usr/local/lib
-Wl,+vallcompatwarnings

/usr/ccs/bin/ld: (Warning) Symbol "OctetStr::valid() const" was
defined both in ../src/.libs/libsnmp++.sl and another file to have
incompatible types (such as CODE and DATA). This may not be supported
in future releases.
/usr/ccs/bin/ld: (Warning) Symbol "OctetStr::valid() const" was
defined both in ../src/.libs/libsnmp++.sl and another file to have
incompatible types (such as CODE and DATA). This may not be supported
in future releases.
/usr/ccs/bin/ld: (Warning) Symbol "OctetStr::valid() const" was
defined both in ../src/.libs/libsnmp++.sl and another file to have
incompatible types (such as CODE and DATA). This may not be supported
in future releases.
/usr/ccs/bin/ld: (Warning) Symbol "OctetStr::valid() const" was
defined both in ../src/.libs/libsnmp++.sl and another file to have
incompatible types (such as CODE and DATA). This may not be supported
in future releases.
/usr/ccs/bin/ld: (Warning) Symbol "UdpAddress::clone() const" was
defined both in ../src/.libs/libsnmp++.sl and another file to have
incompatible types (such as CODE and DATA). This may not be supported
in future releases.
/usr/ccs/bin/ld: (Warning) Symbol "UdpAddress::clone() const" was
defined both in ../src/.libs/libsnmp++.sl and another file to have
incompatible types (such as CODE and DATA). This may not be supported
in future releases.
/usr/ccs/bin/ld: (Warning) Symbols named "OctetStr::valid() const" of
incompatible types (such as CODE and DATA) were found in (unknown) and
(unknown). This may not be supported in future releases.
/usr/ccs/bin/ld: (Warning) Symbols named "UdpAddress::clone() const"
of incompatible types (such as CODE and DATA) were found in (unknown)
and (unknown). This may not be supported in future releases.
/usr/ccs/bin/ld: Unsatisfied symbols:
├В  OctetStr::valid() const(first referenced in snmpGet.o) (data)
collect2: ld returned 1 exit status

HP-UX 11.23 & 11.31 on IA64 work fine, as well as Linux, AIX and Solaris. Full build log is attached.
14 REPLIES 14
Jens Rehsack
Occasional Advisor

Re: g++ linking issue

And here's the config.log
Dennis Handly
Acclaimed Contributor

Re: g++ linking issue

What version of g++ are you using? (It seems to be 4.2.3.)

I'm not sure how you can get this warning:
ld: (Warning) Symbol "OctetStr::valid() const" was defined both in ../src/.libs/libsnmp++.sl and another file to have incompatible types (such as CODE and DATA). This may not be supported in future releases.

Since it has "()" mangled into it, it can only be a function. It seems that your g++ wasn't installed correctly?
Also, it doesn't help that it only says "another file" or "(unknown)".

>ld: Unsatisfied symbols:
├Г OctetStr::valid() const(first referenced in snmpGet.o) (data)

Where should this be defined? You know it was called from snmpGet.o.
(Was that non-ascii char at the beginning really there?)
Jens Rehsack
Occasional Advisor

Re: g++ linking issue

Yes, I'm using g++ 4.2.3.

"OctetStr::valid() const" is defined in a header file as:
class OctetStr ... {
...
bool valid() const { return validity; };
...
};

So I assume, the compiler emits the symbol for this function in each c++ compiled object which includes the

I tried to compile using "-fno-keep-inline-functions", but it doesn't help.

> (Was that non-ascii char at the beginning really there?)
No, it wasn't - some kind of copy'n'waste error.
Dennis Handly
Acclaimed Contributor

Re: g++ linking issue

>"OctetStr::valid() const" is defined in a header file as:
class OctetStr { bool valid() const { return validity; }

>the compiler emits the symbol for this function in each C++ compiled object which includes the

It should. You could try to preprocess your snmpGet.C source to see if that class looks like what you showed.
If it does, your compiler is broken, if it doesn't, it could be evil macros.
Jens Rehsack
Occasional Advisor

Re: g++ linking issue

The precompiled source looks like expected for class OctetStr (I didn't read the entire source). Since HP-UX is a supported platform of snmp++ (http://www.agentpp.com/snmp_pp3_x/snmp_pp3_x.html) I'm afraid that the remaining reason is a buggy compiler. But http://hpux.connect.org.uk/ doesn't list a newer (other) compiler as gcc-4.2.3, could there be another source where to get such a compiler from?
Dennis Handly
Acclaimed Contributor

Re: g++ linking issue

>The preprocessed source looks like expected for class OctetStr

Can you gzip and attach the output of -E?

>could there be another source where to get such a compiler from?

You can get 4.4.3 or 4.3.4 from AllianceONE:
http://www.hp.com/go/gcc

Jens Rehsack
Occasional Advisor

Re: g++ linking issue

> >The preprocessed source looks like expected for class OctetStr

> Can you gzip and attach the output of -E?

Sure.
Dennis Handly
Acclaimed Contributor

Re: g++ linking issue

I have no problems with 4.3.1 on PA. The symbol is defined in the object file.

You could try linking with -Wl,-y_ZNK8OctetStr5validEv to try tracking down that funny linker warning.
Jens Rehsack
Occasional Advisor

Re: g++ linking issue

Link command and output copied and saved in attachment.