I have a .so library that I want to link with C++ code. There's a function called add
on the .so file that respect C interface (its declared as extern "C"). I don t have the .h file so I did something like this but on Android:
#include <iostream>
extern "C" int add(int, int);
//int add(int, int);
int main()
{
std::cout << add(1,1) << std::endl;
}
If I use extern "C" int add(int, int);
I get compilation error about the function add
not being declared. If I use int add(int, int);
it compiles but linking fails (but it could be for other reasons).
Which is the right way to define an extern C functin from a .so?