Solved

What  separates c++ mangle names from their unmangled versions

Posted on 2006-11-01
1
350 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
Comment Utility
>>>> 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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

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…
  Included as part of the C++ Standard Template Library (STL) is a collection of generic containers. Each of these containers serves a different purpose and has different pros and cons. It is often difficult to decide which container to use and …
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.
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.

771 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

11 Experts available now in Live!

Get 1:1 Help Now