Maël Nison
Maël Nison

Reputation: 7353

Workaround for when -whole-library is not available

I'm trying to compile on an environment where the -Wl,-whole-library flag is not supported (emscripten). How can I trick to force the compiler to include the exported symbols ? The solution should met as many of these properties as possible :

I thought about computing a file with something like :

int x = (int)(&func_a)+(int)(&func_b)+...;

But it doesn't work with member functions, which cannot be casted to int (and can be private).

Do you have any idea ?

Upvotes: 1

Views: 98

Answers (1)

Tuan Kuranes
Tuan Kuranes

Reputation: 321

Ideas:

  • Use --whole-library flag before linking the lib you want and just after add -no-whole-library before listing other libs so that only the one you need To be wholly linked is and try add --export-dynamic flag using a linker that supports it.
  • Then dig the nm/objdump/exportmap road http://accu.org/index.php/journals/1372 to export/build link info and for using link info http://runtimecompiledcplusplus.blogspot.fr/ for using exported maps and code so that you can mimic the -Wl in your code.

Upvotes: 0

Related Questions