Relative Content

Tag Archive for c++cmakelinker

How to avoid recursive dependencies on dynamic libraries when compiling executable files?

Assume that I ultimately want to output the string “Hello world”. In this scenario, the dynamic library libhello.so is used to output “hello”, and the dynamic library libworld.so is used to output “world”. The main function calls the interface hello() provided by libhello.so, which outputs the string “hello” and then calls the interface world() provided by libworld.so. The world() function outputs the string “world”. The dependency relationship is as follows: main —-> libhello.so —–> libworld.so, meaning that the main function does not directly depend on libworld.so.