Ubuntu GCC Link Library 的順序問題

今天在 ubuntu 中了招,Makefile 中這樣寫:

結果一直顯示錯誤:

檢查了 libssl-dev 有安裝,也跑去 /usr/lib 建立一些 link,但是問題都沒有解決。

最後原因是這個:

The –as-needed option also makes the linker sensitive to the ordering of libraries on the command-line. You may need to move some libraries later in the command-line, so they come after other libraries or files that require symbols from them.

Ubuntu 自 11.04 後,預設會將 –as-needed 選項打開,所以參數的順序突然變得很重要了,改成這樣就可以了:

參考資料:
https://wiki.ubuntu.com/NattyNarwhal/ToolchainTransition

發佈留言