Accessing C++ .so file from C# within WSL ubuntu.
Hello, . I have some questions regarding creating a dynamic library using c++ and use it in C# on linux machine. In the linux machine, I believe it runs on top of x64 and here is the base code for C++.
#include <iostream>
extern "C" void TestingHelloworld(){
std::cout << "Hello world" << std::endl;
}
And I create it as .so(shared object) file.
in C#,
internal class Program {
// I use it using static extern method such as:
[DllImport("liblinuxprojectconsole.so", CallingConvention.Cdecl)]
public static extern int TestingHelloworld();
static void Main(string[] args) {
Console.WriteLine(TestingHelloworld();
}
Something like that.
And Error message is like:
"System.BadImageFormatException: An attempt was made to load a program with an incorrect format. (0x800700B)" and people are saying it could happen due to version mismatches (x64 vs x32) but I am pretty sure I am using x64 for everything. (I created the .so file using visual studio C++ project with linux).
Can you give me any hints or some direction I have to dig into? Checking on this matter for a day but haven't got any idea. I tried it out using dll with windows but it works perfectly fine. Just not in linux with WSL.
Thank you in advance.