我一直在负责调用从DOTNET核心openzwave在Linux上,我有我的装载C ++库DOTNET核心问题。 基本上任何时候我碰openzwave库我得到未发现异常的DLL。 这里是我的Program.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.InteropServices;
using System.Threading.Tasks;
namespace MinOZWDotNet
{
public class Program
{
[DllImport("MinOZW")]
public static extern int Init();
[DllImport("MinOZW")]
public static extern int Free();
public static void Main(string[] args)
{
Console.WriteLine("Calling Init");
var val= Init();
Console.WriteLine($"retval= {val}");
while (true)
{
if (Console.KeyAvailable)
{
ConsoleKeyInfo key = Console.ReadKey();
if (key.Key == ConsoleKey.Escape)
{
Console.WriteLine("Exit");
break;
}
}
}
Console.WriteLine("Calling Free");
val = Free();
Console.WriteLine($"retval = {val}");
}
}
}
继承人版本其运作。所以
#ifdef __GNUC__
#define EXPORT extern "C"
#define CC
#else
#define EXPORT extern "C" __declspec (dllexport)
#define CC __stdcall
#endif
#ifdef __GNUC__
#include <stdlib.h>
#include <unistd.h>
#include "Defs.h"
#else
#include "Windows.h"
#endif
EXPORT int CC Init() {
return 0;
}
EXPORT int CC Free() {
return 0;
}
继承人的版本,这是给我的错误
#ifdef __GNUC__
#define EXPORT extern "C"
#define CC
#else
#define EXPORT extern "C" __declspec (dllexport)
#define CC __stdcall
#endif
#ifdef __GNUC__
#include <stdlib.h>
#include <unistd.h>
#include "Defs.h"
#else
#include "Windows.h"
#endif
#include "Options.h"
#include "Manager.h"
#include "Driver.h"
#include "Node.h"
#include "Group.h"
#include "Notification.h"
#include "value_classes/ValueStore.h"
#include "value_classes/Value.h"
#include "value_classes/ValueBool.h"
#include "platform/Log.h"
using namespace OpenZWave;
EXPORT int CC Init() {
Manager::Create();
return 0;
}
EXPORT int CC Free() {
Manager::Destroy();
return 0;
}
既openzwave这11b是预期的路径上。 NB时,这个窗口的所有作品汇编。 openZwave在github