Why static library B(linked to a dynamic library C.so) can be linked to static library C.a when building another library A(linked to B)

Viewed 32

I'm building two static libraries A.a and B.a on ubuntu with gcc(version 7.5.0). B is linked to dynamic library libcudart.so(which is a dynamic library of cuda Runtime API). A.a is linked to B.a. Because B.a doesn't resovle symbols in cuda Runtime API, I should link A.a with libcudart.so. But I made a mistake, I linked A.a with libcudart_static.a which is a static library of cuda Runtime API. It surprisingly worked fine. I wonder why the static library libcudart_static.a is allowed to be linked to A.a when the dependency of A is linked to the dynamic library libcudart.so? I know only few thing about static library and dynamic library. Could you explain why this worked from deep inside?

0 Answers
Related