Build shared lib with Go to call .net func

I’m trying to call the TestSay function from the test.so shared library in my Linux environment, but I’m getting an error: Unable to find an entry point named 'TestSay' in shared library 'test.so'. The code samples are included in the fenced code blocks.

I’m running on Ubuntu 22.04.

The error you’re encountering suggests that the function ‘TestSay’ is not exported as an entry point in the shared library ‘test.so’. To fix this issue, you need to modify your code to properly export the function.

Here’s an example of how you can export the ‘TestSay’ function in C++:

// test.cpp

#include <iostream>

extern "C" {
    void TestSay() {
        std::cout << "Hello from TestSay!" << std::endl;
    }
}

To compile this code into a shared library, you can use the following command:

g++ -shared -o test.so test.cpp

After successfully compiling the code, you should be able to call the ‘TestSay’ function from the shared library without any issues.

Note: Make sure that the shared library file (‘test.so’) is located in the same directory as your executable or in a directory specified in the library search path.