Hello all!
my.c
Code:
#define EXPORT __attribute__((visibility("default")))
EXPORT int foo(void);
int foo(void)
{
extern int _new();
return _new();
}
my.cpp
Code:
extern "C" {
#define EXPORT __attribute__((visibility("default")))
EXPORT int foocpp(void)
{
extern int foo();
return foo();
}
}
Then
g++ -shared -fpic -o lib.so my.cpp my.c asm.s
where asm.s contains _new.
I want to call my foocpp using PInvoke from C#:
Code:
using System.Runtime.InteropServices;
class Program{
[DllImport("lib.so")] public static extern int foocpp ();
static void Main(string[] args)
{
int code = foocpp();
System.Console.WriteLine(code);
}
}
But on start using I have an error
symbol lookup error: undefined symbol: foo
Please, help.