Unable to Find an Entry Point (cpp)
This is a similar question to this one.
I want to export a simple function from C++, to be called by C# via PInvoke. This is my function definition:
int fnValue()
{
return 42;
}
And this is the export definition in .h
file:
__declspec(dllexport) int fnValue();
This is how I PInvoke the function:
[DllImport("WhatDll.dll")]
public static extern int fnValue();
Simple, right? But I got a
System.EntryPointNotFoundException : Unable to find an entry 'point named 'fnValue' in DLL "WhatDll.dll'
I use dumpbin to check what's inside WhatDll
, and this is what I have:
00000000 characteristics 4CFB5C95 time date stamp Sun Dec 05 17:34:13 2010 0.00 version 1 ordinal base 4 number of functions 4 number of names
ordinal hint RVA name
1 2 00011014 ?fnValue@@YAHXZ = @ILT+15(?fnValue@@YAHXZ)
Note that there is some gibberish behind the function name fnValue
.
This is pretty puzzling. Any idea?
试着写
extern "C"__declspec(dllexport) int fnValue();
If you compile with a c++ compiler use extern "C"
to export or add a .def file to specify the export names. Additionally __stdcall
might be necessary
上一篇: 无法在DLL'cvextern'中找到名为''的入口点
下一篇: 无法找到入口点(cpp)