Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to load DLL when running the C# project. #1797

Open
Joel0129 opened this issue Nov 14, 2023 · 1 comment
Open

Unable to load DLL when running the C# project. #1797

Joel0129 opened this issue Nov 14, 2023 · 1 comment

Comments

@Joel0129
Copy link

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
@tritao
Copy link
Collaborator

tritao commented Nov 14, 2023

Not sure, maybe you need to annotate the declarations with __declspec(dllexport)?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants