-1

Current I'm building a shared object library using the following command

gcc -I ../include ../../ModuleBDef/include -I ../../ModuleB/include -I ../../ModuleADef/include --shared -fPIC moduleA.c plat_linux.c -o moduleAlib.so

I have moduleBlib.so that contains a symbol that are required by moduleAlib.so. When I use nm to look at the symbols in ModuleAlib.so I can see a U beside that symbol.

I tried adding -L command but the symbol is still undefined.

gcc -I ../include ../../ModuleBDef/include -I ../../ModuleB/include -I ../../ModuleADef/include -L../../ModuleB/src --shared -fPIC moduleA.c plat_linux.c -o moduleAlib.so

How do I resolve this undefined symbol?

tyleax
  • 1,556
  • 2
  • 17
  • 45
  • Does this answer your question? [Linking a shared library with another shared lib in linux](https://stackoverflow.com/questions/19424494/linking-a-shared-library-with-another-shared-lib-in-linux) – frippe Mar 11 '22 at 06:37
  • @frippe looks like my problem was simpler then the link you provided. My naming library convention was incorrect... – tyleax Mar 11 '22 at 06:47

1 Answers1

1

First of all Linux convention is to start library names with lib prefix so your moduleXlib should be libmoduleX. Then you can link libmoduleB.so by adding -lmoduleB after the -L ../../ModuleB/src option.

yugr
  • 19,769
  • 3
  • 51
  • 96