[英]EntryPointNotFoundException in one DLL while seems fine in another
I have two DLLs that I created and they reside in Assets/Plugins. 我创建了两个DLL,它们位于Assets / Plugins中。 One seems to be working fine, the other gives me an EntryPointNotFoundException even though the code look exactly the same to me.
一个似乎工作正常,另一个给我一个EntryPointNotFoundException,即使代码对我来说看起来完全一样。 Maybe there's some setting I missed in VisualStudio?
也许我在VisualStudio中错过了一些设置? What settings do I need?
我需要什么设置?
The one that works looks like this: 一个可行的看起来像这样:
C# C#
[DllImport("winBlinkDetect")]
private static extern void IsSeven(ref int x);
[DllImport("winBlinkDetect")]
private static extern int PrintFive();
void Start()
{
int test = 0;
Debug.Log("x = " + test);
IsFive(ref test);
Debug.Log("x = " + test);
Debug.Log(PrintFive());
}
C++ Header C ++标题
#if _MSC_VER // this is defined when compiling with Visual Studio
#define EXPORT_API __declspec(dllexport) // Visual Studio needs annotating exported functions with this
#define _USE_MATH_DEFINES
#else
#define EXPORT_API // XCode does not need annotating exported functions, so define is empty
#endif
#ifdef __cplusplus
extern "C" {
#endif
void EXPORT_API IsFive(int *y);
void EXPORT_API IsSeven(int *x);
int EXPORT_API PrintFive();
#ifdef __cplusplus
}
#endif
C++ .cpp
void IsFive(int *y)
{
*y = 5;
}
void IsSeven(int *x)
{
*x = 7;
}
int PrintFive()
{
return 99;
}
For the one that doesn't work: C# 对于无效的代码:C#
[DllImport("brain")]
private static extern int GiveNinetyNine();
[DllImport("brain")]
private static extern void IsFive(ref int x);
void Start()
{
int test = 0;
Debug.Log("x = " + test);
IsFive(ref test);
Debug.Log("x = " + test);
Debug.Log(GiveNinetyNine());
}
C ++ Header C ++标题
#if _MSC_VER // this is defined when compiling with Visual Studio
#define EXPORT_API __declspec(dllexport) // Visual Studio needs annotating exported functions with this
#define _USE_MATH_DEFINES
#else
#define EXPORT_API // XCode does not need annotating exported functions, so define is empty
#endif
#include <string>;
#ifdef __cplusplus
extern "C" {
#endif
// test functions
void EXPORT_API IsFive(int *y);
void EXPORT_API IsSeven(int *x);
int EXPORT_API GiveNinetyNine();
#ifdef __cplusplus
}
#endif
C++ .cpp
void IsFive(int *y)
{
*y = 5;
}
void IsSeven(int *x)
{
*x = 7;
}
int GiveNinetyNine()
{
return 99;
}
Dependency Walker shows no exported functions, but exported functions in header file looks good. Dependency Walker没有显示任何导出的函数,但是头文件中的导出的函数看起来不错。 Seems the
h
file is not included into the cpp
file. 似乎
h
文件未包含在cpp
文件中。 To check this put __declspec(dllexport)
inside cpp in function definition. 要检查这一点,请将
__declspec(dllexport)
放在函数定义的cpp中。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.