Reputation: 697
I have written a .dll library with lots of functions and classes in visual studio 2010. When I look at the content of the file with:
dumpbin.exe /EXPORTS myDll.dll
I get long function names with some kind of a function location pointer, which looks like this (second entry in .dll):
2 1 0001100A ?Initialize@codec@codecX@@SANNN@Z = @ILT+5(?Initialize@codec@codecX@@SANNN@Z)
This is somehow hard to read, but I saw "nicer" procedure/function list from other .dll-s, like this:
141 8C 00002A08 PogoDbWriteValueProbeInfo
How can I make that .dll list look that way?
P.S.: my dll source code looks like this:
namespace codecX
{
class codec
{
public:
static __declspec(dllexport) double Initialize(double a, double b);
...
Upvotes: 14
Views: 40111
Reputation: 1089
What you are seeing is C++ mangling of function names.
In case this function needs to be kept as a C++ function you can post process the dumpbin.exe
output to obtain the normal function name using the utility undname.exe
.
Supplied with Microsoft Visual Studio is a utility for undecorating C++ mangled function names called undname.exe
.
It can be used as follows:
C:\>undname ?func1@a@@AAEXH@Z
Microsoft (R) C++ Name Undecorator
Copyright (C) Microsoft Corporation. All rights reserved.
Undecoration of :- "?func1@a@@AAEXH@Z"
is :- "private: void __thiscall a::func1(int)"
Upvotes: 3
Reputation: 13217
This is called name-mangling and happens when you compile C++ with a C++-compiler.
In order to retain the "humand-readable" names you'll have to use extern "C"
when declaring and defining your classes and your functions. i.e.
extern "C" void myFunction(int, int);
See here and also google mixing C and C++
.
Upvotes: 6
Reputation: 7983
You need to pull those static member functions into the global address space and then wrap them with extern "C". This will suppress the C++ name mangling and instead give you C name mangling which is less ugly:
extern "C" __declspec(dllexport) Initialize(double a, double b)
{
codec::Initialize(a, b);
}
and then remove the __declspec(dllexport) on your static member functions:
class codec
{
public:
static double Initialize(double a, double b);
}
Upvotes: 13