I have around 26 static libraries such as liba.a, libb.a, libc.a, ..., libz.a . There are two catches here: 1) circular dependencies between for example liba.a and libb.a ; 2) some lib*.a has static global registration code which is unreferenced, but shall NOT be stripped away. Thanks to stackoverflow, I managed to solve above two problems with the ld option -Wl,--whole-archive -la -lb -lc -ld -le ...(omitted)... -lz -Wl,--no-whole-archive -lpthread -lm -ldl -lrt -fopenmp , and the executable binary works! It is also explained in ld linker question: the --whole-archive option Now I need to