Solved

What  separates c++ mangle names from their unmangled versions

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

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

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

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…
What is C++ STL?: STL stands for Standard Template Library and is a part of standard C++ libraries. It contains many useful data structures (containers) and algorithms, which can spare you a lot of the time. Today we will look at the STL Vector. …
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
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.

774 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