简体   繁体   English

创建包含第三方SDK的c ++ DLL

[英]Creating c++ DLL including third party SDK

I am trying to get a third party reconstruction library ReconstructMe working by creating a c++ dll and call it within unity(c#). 我正在尝试通过创建c ++ dll并在unity(c#)中调用它来使第三方重建库ReconstructMe工作。

I have get it working using supplied dll but calling unmanaged function calls are hitting performance on every update for multiple functions eg: 我已经使用提供的dll使它正常工作,但是在每次更新多个功能时调用非托管函数调用都会降低性能,例如:

on every update I am calling below necessary calls: 在每次更新时,我在以下必要的电话中致电:

reme_sensor_grab
reme_sensor_prepare_images
reme_sensor_track_position
reme_sensor_update_volume
reme_surface_generate 

For optimization, the idea is if I can make a new DLL including all above functions, calls and this DLL import function will call once per update from unity(c#) or may be call it just once and get data from callbacks. 为了进行优化,我的想法是,如果我可以创建一个包含所有上述函数的新DLL,则调用,并且此DLL导入函数每次从unity(c#)更新时都调用一次,或者可以仅调用一次并从回调中获取数据。

I have simply used below code to check if I am able to get it working, unfortunately I am getting LNK2019: 我只是使用下面的代码来检查是否能够正常工作,不幸的是我得到了LNK2019:

RemeDLL.obj : error LNK2019: unresolved external symbol __imp_reme_context_create referenced in function “private: void __cdecl RemeDLL::StartScan(void)” (?StartScan@RemeDLL@@AEAAXXZ)
1>c:\Projects\RemeDLL\x64\Debug\RemeDLL.dll : fatal error LNK1120: 1 unresolved externals

#include <iostream>
#include <reconstructmesdk/reme.h>
using namespace std;

class RemeDLL
{
    __declspec(dllexport) void StartScan()
    {
        // Create a new context
        reme_context_t context;
        reme_context_create(&context);
        //...
    }
};

Here are definitions from SDK: 这是SDK的定义:

typedef struct _reme_context* reme_context_t;

LIBRECONSTRUCTMESDK_LIBRARY_INTERFACE
reme_error_t reme_context_create(reme_context_t *c);

#define LIBRECONSTRUCTMESDK_LIBRARY_INTERFACE __declspec(dllimport)

Can someone please suggest or give pointers how can I go around this ? 有人可以提出建议或提出建议我该如何解决? Do I need some kind of layers for linking dll to import first and then call dll to export function, please advice. 我是否需要某种类型的层来首先链接dll,然后再调用dll来导出函数,请告知。 Thanks. 谢谢。

  1. Add paths to ReconstructMe inc and lib folders to your project properties; 将ReconstructMe inclib文件夹的路径添加到项目属性;
  2. Add line #pragma comment(lib, "LibReconstructMeSDK.lib") to your source code. #pragma comment(lib, "LibReconstructMeSDK.lib")#pragma comment(lib, "LibReconstructMeSDK.lib")到您的源代码中。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM