Solved

What  separates c++ mangle names from their unmangled versions

Posted on 2006-11-01
1
360 Views
Last Modified: 2008-02-01

I am having trouble linking an application.   I can link using an old .a file, but with the newer .a file,  the link fials because it can't find _ZN3MPI2Op4InitEPFvPKvPviRKNS_8DatatypeEEb which c++filt demangles to:  

MPI::Op::Init(void (*)(void const*, void*, int, MPI::Datatype const&), bool)

The C version of this entry point is:  MPI_Op_Create

And, indeed in the old .so file (which I can link), there is a reference to MPI_Op_Create and no reference to ZN3MPI2Op4InitEPFvPKvPviRKNS_8DatatypeEEb whereas in the new .so file (which I cannot link),
there is a reference to _ZN3MPI2Op4InitEPFvPKvPviRKNS_8DatatypeEEb but none to MPI_Op_Create.

Unfortunately, I can't recreate the old .so file, so I have to work from the new one.  

The .a file from which the .so files are built contains references to both _ZN3MPI2Op4InitEPFvPKvPviRKNS_8DatatypeEEb and MPI_Op_Create.  (The two .so files are built from different versions of those .a files, but all versions of the .a files contain references to both entry points).

What might have changed to cause the new .so file to reference _ZN3MPI2Op4InitEPFvPKvPviRKNS_8DatatypeEEb instead of MPI_Op_Create.  

Thanks,
  Ken







http://www.mainserver.state.mn.us/bookmgr-cgi/bookmgr.exe/handheld/BOOKS/IBMBK.Z6UNIX.IPEZPS00.BOOK/4.156?SHELF=IBMBK.Z6UNIX.BPXZSH51.BKSHELF&DT=20010104150826


0
Comment
Question by:klopter
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 39

Accepted Solution

by:
itsmeandnobodyelse earned 500 total points
ID: 17850971
>>>> What might have changed to cause the new .so file to reference
>>>>_ZN3MPI2Op4InitEPFvPKvPviRKNS_8DatatypeEEb instead of MPI_Op_Create.  

You need to switch off C++ name mangling when the function was declared. Normally you do that in the header file:

#ifdef __cplusplus
extern "C"
{
#endif

typedef struct OpTag
{
     void Init(void (*)(void const*, void*, int, MPI::Datatype const&), bool);
} Op;

#ifdef __cplusplus
}
#endif


You also could try to  put the extern "C" around the include of the header file where the Init function was defined.

// some.cpp

extern "C"
{
    #include <op.h>
}

Regards, Alex
0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Errors will happen. It is a fact of life for the programmer. How and when errors are detected have a great impact on quality and cost of a product. It is better to detect errors at compile time, when possible and practical. Errors that make their wa…
Templates For Beginners Or How To Encourage The Compiler To Work For You Introduction This tutorial is targeted at the reader who is, perhaps, familiar with the basics of C++ but would prefer a little slower introduction to the more ad…
The goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…
The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.

622 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question