清华邓博士视频中提到 如果按照$(CCOPTS) -L . -lsum -o main mian.c
编译看到lsum的时候因为现在不需要会忽略掉,等到后面需要的时候已经忘记了这个的存在了。
所以就会用下面的一条指令,先发现需要,再提供解决方案。
即先需求后供给(不求无助)
贴一段来自stackoverflow的话
即循环依赖的解决方式
If a static library depends on another library, but the other library again depends on the former library, there is a cycle. You can resolve this by enclosing the cyclically dependent libraries by -( and -), such as -( -la -lb -) (you may need to escape the parens, such as -( and -)). The linker then searches those enclosed lib multiple times to ensure cycling dependencies are resolved. Alternatively, you can specify the libraries multiple times, so each is before one another: -la -lb -la.