Search code examples
clinuxshared-librariesgnureadline

Is it possible to call a function in a shared library that has not been declared?


The short version: I'm trying to use a function in a shared library that hasn't been declared in a header file. Is it possible? If so, how?

The long version: I'm trying to use GNU readline-7.0 as a shared library. Unfortunately it will echo input by default unless you turn it off with an api call. Sadly this api call wasn't declared in their header, because someone forgot. see details here Note: I can't update to a newer readline, so I'm stuck with this library. How do I use this undeclared function?


Solution

  • As noted in the linked bug, there is no external declaration in the header file even though the function exists in the implementation.

    The link also shows the fix with the added declaration:

    extern int rl_tty_set_echoing PARAMS((int));
    

    So you can add this in your code right after #include <readline.h>