undefined reference to 'dlopen'

1

I'm trying to load a .so file, but this title error is showing up. Can anyone help me?

    #include <iostream>
    #include <dlfcn.h>
    #include <stdio.h>

    using namespace std;

    int main()
    {
      void *abrir;
      abrir = dlopen("EZClient.so", RTLD_NOW);

    if(!abrir)
    {
      printf("%s\n", dlerror());
      return -1;
    }
    return 0;
    }
    
asked by anonymous 18.09.2017 / 22:07

1 answer

2

The implementations of the dlopen and dlerror functions are in a library called libdl.so .

So, for you to compile this program, using g ++, you have to execute the following command line

g++ -o programa programa.cpp -ldl

that is, add the library using the -ldl

    
19.09.2017 / 01:39