I am trying to implement a dynamic library and connect it in my program. The library will work with ncurses, but I don't think the error is related to this.
Source library lib.cpp:
#include "panel.h" void win() { initscr(); PANEL* root_panel = new_panel(stdscr); } Source program main.cpp:
#include <iostream> #include <dlfcn.h> int main() { void* library_handler = dlopen("./lib.so", RTLD_NOW | RTLD_GLOBAL); if ( ! library_handler) { std::cout << dlerror() << std::endl; return 1; }; return 0; } Build commands:
$ g++ -ldl main.cpp -o main $ g++ -fpic -c lib.cpp -o lib.o $ g++ -shared -o lib.so lib.o Result of performance:
$ ./main ./lib.so: undefined symbol: stdscr gcc version 5.3.0
Apparently you need to specify / change some compilation or linking options, but I can not google anything.