Topic
  • 3 replies
  • Latest Post - ‏2013-01-25T15:48:48Z by Dwayne_M
SystemAdmin
SystemAdmin
549 Posts

Pinned topic xlc++_r7 not able to link with third party lib

‏2013-01-25T12:38:54Z |
Hi,

I have a libjson.a library, which has been compiled using g++ for 64-bit using -maix64 flag.
I am using xlc++_r7 as the compiler for my application and am using -q64 as the option and linking with the libjson library.

I get the following errors:
ld: 0711-317 ERROR: Undefined symbol: .internalJSONNode::Fetch() const
ld: 0711-317 ERROR: Undefined symbol: .internalJSONNode::deleteInternal(internalJSONNode*)
ld: 0711-317 ERROR: Undefined symbol: .JSONWorker::parse(const std::basic_string<char,std::char_traits<char>,std::allocator<char> >&)

I have verified that the libjson.a has object files that are 64-bit.
I also see that the symbols are very much present in the object files, for e.g.:
/home/build/libjson/libjson/Objects_static>nm -X64 internalJSONNode.o | grep deleteInternal
.ZN16internalJSONNode14deleteInternalEPS T 17628
ZN16internalJSONNode14deleteInternalEPS D 28288
ZN16internalJSONNode14deleteInternalEPS d 28288 24

The whole linking process works fine when I compile libjson using xlc++_r7.

So does that mean xlc++_r7 allows linking with only xlc++_r7-compiled libs?

Thanks,
Yash
Updated on 2013-01-25T15:48:48Z at 2013-01-25T15:48:48Z by Dwayne_M
  • Dwayne_M
    Dwayne_M
    27 Posts

    Re: xlc++_r7 not able to link with third party lib

    ‏2013-01-25T13:58:54Z  
    You cannot mix objects compiled with g++ with objects built with xlc++. The two compilers have different C++ object models, name mangling etc.
    Dwayne Moore
    IBM Compilers Product Management
  • SystemAdmin
    SystemAdmin
    549 Posts

    Re: xlc++_r7 not able to link with third party lib

    ‏2013-01-25T15:12:52Z  
    Thanks for the response.

    If we have libraries received from third parties without their original source code, what is the way by which we can link them to our application?

    -Yash
  • Dwayne_M
    Dwayne_M
    27 Posts

    Re: xlc++_r7 not able to link with third party lib

    ‏2013-01-25T15:48:48Z  
    Thanks for the response.

    If we have libraries received from third parties without their original source code, what is the way by which we can link them to our application?

    -Yash
    You cannot link them to your application. The link fails because g++ uses a different way to "mangle" C++ function names than xlc++ does. But even if you could get past this and link successfully. There are other differences between g++ and xlc++, such as exception-handling and how objects are laid-out in memory that would prevent the application from running correctly (or at all).

    You should have the provider of the library give you a version that was built with xlc++.

    Dwayne Moore
    IBM Compilers Product Management