簡體   English   中英

一個DLL中的EntryPointNotFoundException,而在另一個DLL中似乎很好

[英]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.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM