(shared library under the name "monster") |
To use a symbol, it must be declared before its first use.
As I mentioned, it's conventional to have a header file associated with a library which contains forward declarations of every symbol with external linkage. The definitions of the symbols should appear in the library itself.
This was the header file I was referring to. Create a
monster.h which contains forward declarations of the externally-linked symbols in
libmonster.so.
Include that file from
textgame.cpp.
Get a dynamic library handle using dlopen(3) from <dlfcn.h>.
Use dlsym(3) to obtain pointers to the symbols you need.
That's it.
You can find a decent example, here:
http://stackoverflow.com/a/497158
Plenty more are accessible with some searching.
P.S.:
"external libraries" aren't necessarily dynamic. Static libraries don't require C linkage (because the symbols are visible to the linker), and the so-called "header-only libraries" compile directly into the TUs (translation units) they're included in.
P.P.S.:
Maybe the cppreference pages on storage classes and language linkage will help:
http://en.cppreference.com/w/cpp/language/storage_duration
http://en.cppreference.com/w/cpp/language/language_linkage