我有一个AR应用程序 . 我使用visual studio 2013创建了一个c dll . 我在我的AR应用程序中使用这个dll,如下所示:
**In private members region :**
[DllImport ("DllExample")]
private static extern int func(int x, int y);
.......
**In a C# function :**
if (func((int)pos.x, (int)pos.y) == -1) {
...
}
else {
...
}
我的统一应用程序工作精细统一编辑我为Android构建这个应用程序 . 当我在Android设备上运行它时,它不起作用 .
C dll的内容:
// dllmain.cpp : Defines the entry point for the DLL application.
#include "stdafx.h"
#include <opencv2\core\core.hpp>
#include <opencv2\highgui\highgui.hpp>
#include <opencv2\imgproc\imgproc.hpp>
#include <fstream>
#include <iostream>
extern "C" __declspec(dllexport) int func(int x, int y);
BOOL APIENTRY DllMain( HMODULE hModule,
DWORD ul_reason_for_call,
LPVOID lpReserved
)
{
switch (ul_reason_for_call)
{
case DLL_PROCESS_ATTACH:
case DLL_THREAD_ATTACH:
case DLL_THREAD_DETACH:
case DLL_PROCESS_DETACH:
break;
}
return TRUE;
}
__declspec(dllexport) int func(int x, int y)
{
cv::RNG rng(12345);
cv::Mat image0, image, gray, mask;
int ffillMode = 1;
int loDiff = 20, upDiff = 20;
int connectivity = 4;
int isColor = true;
bool useMask = false;
int newMaskVal = 255;
return x;
}
在Unity C#文件中,如果我删除调用dll函数,应用程序在我的Android设备上运行正常 . 我使用免费的统一版本 . 如何在移动设备上使用c dll?
2 回答
您需要将dll文件放在Android插件文件夹中,才能使用它 . Android插件文件夹是 Assets/Plugins/Android . 如果它没有退出就创建它 .
EDIT: 根据我的研究,非专业人士不提供Unity插件 . 免费和专业版Unity 5均支持Unity插件 . 您需要更新到Unity 5.这是一个让Unity支持Unity免费版插件的人.2686374 .
Android在Linux系统上运行 - DLL文件通常是为Windows编译的字节码 .
答案来自here