[英]Dll become unable to load when calling function from another dll
Now I have a Unity (C#) project, which calls my C++ project from a dll. 现在,我有一个Unity(C#)项目,该项目从dll调用我的C ++项目。 They both worked fine, so as calling C++ functions from Unity. 它们都工作正常,因此可以从Unity调用C ++函数。
However, when I try add one line to call a function another library (NLOpt library, from another dll) in the C++ project, the generated dll becomes unable to be loaded in the Unity project. 但是,当我尝试在C ++项目中添加一行以调用函数的另一个库(NLOpt库,来自另一个dll)时,生成的dll变得无法加载到Unity项目中。
Plugin.h Plugin.h
extern "C" __declspec(dllexport) bool __stdcall LoadData(int agent_num, int frame_num, float* data);
Plugin.cpp Plugin.cpp
#include "Plugin.h"
#include <nlopt.h>
__declspec(dllexport) bool __stdcall LoadData(int agent_num, int frame_num, float* d)
{
...
nlopt_opt opt = nlopt_create(NLOPT_LN_COBYLA, 3); //this line
}
As I add the line above, Unity will the following error: 当我在上面添加行时,Unity将出现以下错误:
Plugins: Failed to load 'Assets/Plugins/BirdOpti/BirdOpti.dll'
and 和
DllNotFoundException: Opti
I have tried couple of times so I am sure the problem is the line. 我已经尝试了几次,所以我确定问题出在线路上。
Did I do anything wrong? 我做错了吗?
将使用过的dll文件也添加到插件目录即可解决该问题。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.