CppSharp
CppSharp copied to clipboard
Unable to load DLL when running the C# project.
Brief Description
I am attempting to develop a simple CppSharp project. The implementation of the Setup function in the ILibrary interface is as follows:
public void Setup(Driver driver)
{
//throw new NotImplementedException();
var options = driver.Options;
options.GeneratorKind = GeneratorKind.CSharp;
options.OutputDir = @"D:\Project\Cppsharp\Sample\output";
var module = options.AddModule("CppClass");
module.IncludeDirs.Add(@"D:\Project\Cppsharp\Sample\include");
module.Headers.Add("Sample.h");
}
Upon execution of ConsoleDriver.Run(new CppClass()), two files named CppClass.cs and CppClass-symbols.cpp are generated within the designated folder. The files CppClass.cs and CppClass-symbols.cpp are copied into the C# project, and a Sample object is instantiated using CppClass.Sample sample = new CppClass.Sample(1,2).
However, upon running the C# project, an error message of "Unable to load DLL 'CppClass' or one of its dependencies" arises. Could you kindly advise on what steps I may be omitting?
OS: Windows
Used headers
class Sample
{
public:
int a;
int b;
Sample(int a, int b){
this->a=a;
this->b=b;
};
};
Used settings
Target: MSVC/GCC/Clang
Other settings
Stack trace or incompilable generated code
Not sure, maybe you need to annotate the declarations with __declspec(dllexport)?