Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to resolve an unresolved symbol?
    text
    copied!<p>Greetings.</p> <p>I'm having a problem dynamically linking my lib to my program. Here's what's happening : I'm developing a modular program and testing the module system. The thing is my modules uses some class that are defined in the main binary : some abstract classes, which don't cause any issues, and a very concrete class, which just can't be resolved.</p> <p>I'm using the dlopen / dlsym / dlclose set of functions. And I compile using g++.</p> <p>The thing is : if I ask dlopen to load all the symbols, then it fails telling me <code>"undefined symbol: _ZNK3zia3api8DataTreecvRKSsEv</code> But if I launch dlopen in lazy mode, it will only happen at the first usage of the so-called class (and crash right after that).</p> <p>So this is the "DataTree" class, and I want to make it available for both the main binary and the modules. I already tried to compile it in each of the binaries : as I expected, it didn't work. I also tried to make it entirely inline, but it's as useless as my other attempt. I tried to compile the main binary with the option "-rdynamic". No changes.</p> <p>I've been searching, asking to friends since yesterday but nobody seems to know how to solve this kind of problems.</p> <p>I compile the objects of the module with the option -fPIC, like this :</p> <pre><code>g++ -Wall -fPIC -c mysource.cpp </code></pre> <p>And then I use this line to make the library :</p> <pre><code>g++ -shared -Wl,-soname,mylib.so.1 -o mylib.so mysource.o </code></pre> <p>I suppose the best solution would be to not compile the object within the library, but to make the symbol available from the main binary. So the question is : how to do so ? (and is it what I must do ?)</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload