2016-08-17 94 views
0

我有两个我创建的DLL,它们驻留在Assets/Plugins中。一个似乎工作正常,另一个给我一个EntryPointNotFoundException,即使代码看起来完全一样。也许我在VisualStudio中错过了一些设置?我需要什么设置?EntryPointNotFoundException在一个DLL中,虽然在另一个似乎很好

的作品的一个看起来是这样的:

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; 
} 

回答

1

Dependency Walker显示没有导出的函数,但在头文件导出的函数看起来不错。似乎h文件未包含在cpp文件中。在函数定义中检查这个放在cpp里面__declspec(dllexport)

+0

这是一个非常好的工具,谢谢。当我对正在工作的那个进行检查时,所有功能都显示为未加工。当我对不工作的那个进行检查时,根本不显示任何功能。 – mBajema

+0

@mBajema好的迹象,请检查你已经编译了这个示例平台的两个dll - x86或x64 – Nikita

+0

我将它们都设置为配置管理器中的发布配置平台x64。 – mBajema

相关问题