How to resolve undefined symbols like functions defined inside another libraray
13:37 04 Jan 2026

I have two libraries liba.so and libb.so wherein libb.so links liba.so. The libraries are getting built successfully but when I do nm libb.so, it shows liba.so's library functions as U(undefined symbol). How do I fix this by making U to T .

lib_a.cpp

extern "C" void printa() {

}

build command

gcc -shared -fPIC -o liba.so ./lib_a.cpp

lib_b.cpp

extern "C" void printa();

void printb() {
    printa();
}

build command

gcc -shared -fPIC -o libb.so ./lib_b.cpp -L../lib_a -la

nm liba.so

0000000000001104 T printa

nm libb.so

                 U printa
c++ linker nm