-1

In my main source code, I defined a function named findConst(). In the same source, I'm loading a shared object (.so) using dlopen() et dlsym().

In this shared object, I have some code that use findConst() ... but unfortunately, when I run my progy, I got a lookup error : ./Selene: symbol lookup error: ./SelDirectFB.so: undefined symbol: findConst

What I need to do to solve this issue ?

Thanks

  • 1
    Needing to do this is almost always an indication of poor design. But if you really must then have a look at [How to call a function in the main program from a dynamically loaded shared librar](http://stackoverflow.com/questions/17081131/how-to-call-a-function-in-the-main-program-from-a-dynamically-loaded-shared-libr) – kaylum Apr 15 '16 at 22:41
  • Thanks for pointing me out this other question I wasn't able to found : -Wl,--export-dynamic makes it working. But do you consider that as a poor design ? The goal is not to create a library shared among several tools, the goal here is to create a plugin dedicated to a particular program. It's only to make DirectFB usage optional, depending on which system my tool is running. – destroyedlolo Apr 16 '16 at 00:00

1 Answers1

1

You can't do that and if you succeed to do so you shouldn't. Do the opposite, define findConst() in the shared object and then load it in the main program with dlsym().

Or even better, link the main program to the shared object and call the function directly.

Iharob Al Asimi
  • 52,653
  • 6
  • 59
  • 97