EntryPointNotFoundException在一个DLL中,而在另一个DLL中似乎很好
EntryPointNotFoundException in one DLL while seems fine in another
我创建了两个dll,它们位于资产/插件中。一个似乎工作得很好,另一个给了我一个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中。
相关文章:
- 在 Windows 上,是否可以让 dll 在不使用 PATH 环境变量的情况下在另一个文件夹中查找依赖项?
- 在 C++/CLI 中将 .NET 事件从一个 DLL 引发到另一个 DLL
- C++ |DLL / EXE - 如何从导出的类调用另一个类方法?
- 引用另一个文件夹中的.dll
- C++将包含的库 (ref DLL) 从根目录更改为另一个位置
- 将 std::string 作为参数从一个 DLL 传递到另一个 DLL 引发访问冲突错误
- Java加载DLL,该DLL从JNI中的另一个DLL导出方法
- 如何在另一个 DLL 上使用 '/DELAYLOAD' 的 DLL
- 当从一个应用程序调用时,在DLL方法中创建COM接口指针是有效的,但当从另一个应用软件调用时则无效
- 在另一个项目中将模板函数用作dll
- 用C++为java构建一个dll,它正在调用另一个dll(Eclipse上的JNI)
- 是否有从另一个DLL中加载DLL的最佳实践
- Dll 注入 - 在另一个进程中编写本机代码
- 如何将dll注入另一个进程
- 如何正确删除从另一个DLL接收的派生对象
- 在 jmpq 上崩溃到另一个 dll 中的函数与 mingw64
- 将一个 dll 导入另一个 dll C++
- Visual Studio,C++,在另一个DLL导出的类中使用DLL导出的类
- 一个C++客户端无法使用我们新的 COM 注册的 .NET .dll加载,另一个客户端可以正常工作
- 从另一个 dll 链接动态 dll 会导致错误