Symbol resolution with jextract/clang

90 views Asked by At

I'm trying to use a cpp library in java and for that I use jextract.

My .h looked like this :

int get_Unique_PrimaryKey_interface ();

While checking the .so with nm -C the symbol was present with the name get_Unique_PrimaryKey_interface(). While running java I had the following error

 symbol lookup error: XXXXX.so: undefined symbol: get_Unique_PrimaryKey_interface 

After some time I manage to fix that by changing my .h to the following :

#ifdef __cplusplus
extern "C" int get_Unique_PrimaryKey_interface ();
#else
extern int get_Unique_PrimaryKey_interface ();
#endif

The symbol is the .so now is get_Unique_PrimaryKey_interface and the java does call the C function.

The problem goes further when I try to call function from other library that I cannot change and do not use the extern keyword. Jextract is always looking for the symbol as generated with extern but the libraries contains the symbols generated without it.

I'm trying to look for a clang flag to pass to jextract so it will look for both symbols. Does anyone know if there is a way to do that ?

0

There are 0 answers