I don't have time to go through your code or understand the issue and you do not mention the OS, but you can look at what I wrote with code examples for macOS (UNIX) in this Wiki article.
Thank you, but what you've covered in your article (creating a library and calling it's functions) is already working in my test setup. What does not is the "callback" mechanism, when the library calls a function of the dynamically linked executable. (The statical - where i simply give the function's address to the library - is working.)
Isn't it that the 'caller' variable was declared as pointer to fn in mylib, while the 'caller' in mytest is just a function, not a var?
It has to be a var which points to a function, since the function does not exists in the library. It works in C, if the executable is linked dynamically. This is in the C lib:
extern int caller(int *ptr);
int mylib_d(int *d);
int mylib_d(int *d)
{
*d += 5;
return caller(d);
}
And this is in the C executable:
int caller(int *ptr)
{
*ptr += 5;
return *ptr + 5;
}
This approach also works in the statically linked Pascal executable, although i have to set that variable manually via a setter function of the library.
Have you set the LD_LIBRARY_PATH env variable?
No, but it is not needed in this case, as i used the full path to the library, not just it's name.