Kristofer
Kristofer

Reputation: 3269

Exported function names does not contain argument list

I'm creating a plugin DLL using c++ in Eclipse.

When trying to load the plugin I get an error:

?CTC_Cleanup@YAXXZ not found. Function is not available in myplugin.dll

When comparing another working plugin with my plugin using Dependency Walker I notice that the function name in the other plugin is: "void CTC_Cleanup(void)", enabling "Undecorate C++ functions" => "?CTC_Cleanup@YAXXZ".

In my plugin the function name is: "CTC_Cleanup", enabling "Undecorate C++ functions" makes no difference.

My C++ function declarations in the .h file are all decorated with "__declspec(dllexport)" and surrounded using

extern "C" {
...
...
...
}

/Kristofer

Upvotes: 1

Views: 320

Answers (3)

DrPizza
DrPizza

Reputation: 18340

It's looking for a mangled name, so you don't want extern "C".

?CTC_Cleanup@YAXXZ is using the VC++ name mangling for a function taking void and returning void named CTC_Cleanup.

However, you are using g++ 3.x or 4.x, and g++ uses a different mangling scheme that is incompatible.

Build your library using VC++, or else figure out how to make g++ use VC++ name mangling.

Upvotes: 1

ur.
ur.

Reputation: 2947

Remove extern "C", then it should work: I guess your plugin will then export the function under the expected name.

Upvotes: 0

unwind
unwind

Reputation: 399703

Argument names (actually argument types, the formal names really shouldn't matter at this level) shouldn't matter using C linkage; in C, you don't have any overloading so the function name itself should be enough, the types of the arguments don't matter.

Upvotes: 0

Related Questions