私はLinux上でdotnet coreからopenzwaveを呼び出すタスクがありましたが、私のC++ライブラリを読み込むdotnetコアに問題があります。基本的に私はopenzwaveライブラリに触れるたびに、例外が見つからないdllを取得します。 は、ここに私のProgram.csの相続人 System.DllNotFoundException:dotnetコアでDLLを読み込めません
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
#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と、このLIBを与えている相続人
#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;
}
バージョンを作品の.soのバージョンです予想される経路上にある。 N.Bウィンドウでコンパイルすると、これはすべて動作します。 openZwave on github
私はこのソースをMinOZWのサンプルから取り出して、実行可能ファイルを作成し、それを変更しました。実行ファイルはlinuxで動作します。 – Mark
CRLが "MinOZW.so"を見つけることができないので、この例外([docs](https://msdn.microsoft.com/en-us/library/system.dllnotfoundexception.aspx)を読む)がスローされます。それは "大文字と小文字を区別"問題だと思ったが、私はそれを除外するように動作するバージョンを持っています... – Seididieci
私はリンカが非バージョン化libopenzwaveを探す必要があると思います。あなたの助けをありがとう – Mark