[英]C++ DLL “Cannot Find Entry Point”
因此,我就此着眼于SO的其他问题。 由于某些原因,我仍然遇到此问题。
“找不到入口点”
我的CPP
extern "C"{
__declspec(dllexport) int GetPose()
{
if (currentPose == myo::Pose::none)
return 0;
else if (currentPose == myo::Pose::fist)
return 1;
else
return -1;
}
}
我的C#
public partial class MainWindow : Window
{
[DllImport("MyoWrapper.dll", CallingConvention = CallingConvention.StdCall)]
public static extern int GetPose();
public MainWindow()
{
InitializeComponent();
DispatcherTimer timer = new DispatcherTimer();
timer.Interval = new TimeSpan(100);
timer.Tick += (sender, args) =>
{
int x = GetPose();
};
timer.Start();
}
}
造成此错误的最可能原因如下
extern "C"
块中定义GetPos
方法。 这将导致该名称作为C ++混乱的名称发出,因此该名称在DllImport
属性上是错误的 MyoWrapper.dll
文件与可执行文件不在同一个路径中,因此找不到该文件 鉴于错误是“切入点”,我将下注#1是原因。
解决方案还不错。
我试图将带有主程序的程序转换为DLL,因此显然我要公开的方法不是入口点。 一旦公开了所有方法并将main设置为C#的入口点,它就可以正常工作。
[DllImport("MyoWrapper.dll", EntryPoint = "main")]
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.