![](/img/trans.png)
[英]EntryPointNotFoundException in advapi32.dll while starting application
[英]EntryPointNotFoundException in one DLL while seems fine in another
我創建了兩個DLL,它們位於Assets / Plugins中。 一個似乎工作正常,另一個給我一個EntryPointNotFoundException,即使代碼對我來說看起來完全一樣。 也許我在VisualStudio中錯過了一些設置? 我需要什么設置?
一個可行的看起來像這樣:
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 ++標題
#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;
}
對於無效的代碼: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 ++標題
#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沒有顯示任何導出的函數,但是頭文件中的導出的函數看起來不錯。 似乎h
文件未包含在cpp
文件中。 要檢查這一點,請將__declspec(dllexport)
放在函數定義的cpp中。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.