I use dlopen to combine the characters of a dynamically loaded library and its host, and in the host I have a class:
class Foo {
public:
Foo() {}
void bar() {}
};
int main() {
return 0;
}
I compile this with g++ -Wl,--export-dynamic -o test test.cppand checking for characters with nm -g test. I expect that symbols will exist in the executable _ZN3FooC1Evand _ZN3FooC2Ev, since they need a dynamic library, but they will not be displayed if I do not use them without commenting on the above line. I believe that it is optimized because GCC believes that it is not needed.
How to force the constructor and methods of Foo to be included in the host binary?
source
share