"double free or corruption (out)" when linking to a library which works fine in C and JNI

I have a shared library with its .h. When linking the K/N executable to the .so file/s the double free or corruption (out) error comes out during building under the test Gradle task. I thing this library relies on many others bundled with its SDK but the developer explicitly says to link only to one specific .so.

When linking all the other .so files bundles, the error changes to free(): invalid pointer

Notice that the library works fine when loaded and used trough a JNI or from C.

Furthermore I noticed that the K/N linker does not search for libs in $PATH while the cinterop one does; the K/N linker options needs the full file name with the command -l:libfoo.so while the cinterop dynamically add stuff to the library name -lfoo. Why?