Solved

What  separates c++ mangle names from their unmangled versions

Posted on 2006-11-01
1
352 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
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Unlike C#, C++ doesn't have native support for sealing classes (so they cannot be sub-classed). At the cost of a virtual base class pointer it is possible to implement a pseudo sealing mechanism The trick is to virtually inherit from a base class…
Introduction This article is the first in a series of articles about the C/C++ Visual Studio Express debugger.  It provides a quick start guide in using the debugger. Part 2 focuses on additional topics in breakpoints.  Lastly, Part 3 focuses on th…
The viewer will learn how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.
The viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.

895 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

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now