tags:

views:

78

answers:

3

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

A: 

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.

unwind
A: 

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

ur
Removing the extern C gives the following:"_Z11CTC_Cleanupv"Undecorate on/off makes no change.
Kristofer
+1  A: 

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.

DrPizza
One way to use *arbitrary* name mangling is to call GetProcAddress to load the function address at run time.
Rob Kennedy
Thx for the hints, made me find the following links:http://www.mingw.org/wiki/MSVC_and_MinGW_DLLshttp://blog.outofhanwell.com/2006/05/01/linking-msvc-libraries-with-mingw-projects/
Kristofer