: 1.
: 關於(ii),把solver.o和helper.o弄成libsolver.a,不用把solver.h和helper.h一起
: 弄到libsolver.a裡面嗎??
不用, library is a collection of object files, so don't need to include header
files.
: 2.
: 在makefile裡面,list of dependencies是只能放.o檔嗎?那.a檔可以放嗎?
Dependencies can be anything (files or even target/tokens in the makefile).
: 3.
: g++ 連結library archive一定要先用-L指定路徑,再用-l指定lib檔名嗎?
: 如果操作在同一個目錄下,可不可以直接寫.a檔在g++ -o main.o的後面?
Yes, you can do "g++ -o <execFile> main.o libsolver.a".
However, in this problem, I would like you to practice the "-l" and "-L"
options.
: -lz是指連接zlib的意思嗎???
Yes.
: 4. 如果成功弄出執行檔,要如何執行它呢?
Please see Post #2247
--
※ 編輯: ric2k1 來自: 140.112.21.241 (10/08 14:21)
1F:推 newmilktea:請問-L後面的路徑如何才會連到HW1.1.P4 10/08 18:49
2F:推 anfranion:-L後面接當前目錄(.)就好了 10/08 18:52
3F:→ newmilktea:不管我怎樣打,它都一直去/usr/bin/ld找檔案?!! 10/08 18:52
4F:推 newmilktea:g++ -o hw1.1.p4 main.o -L$./ -lsolver-lz 10/08 18:58
5F:→ newmilktea:是這樣嗎? 10/08 18:58
6F:→ ric2k1:不用 $ 10/08 19:45
7F:推 newmilktea:它還是出現/usr/bin/ld:cannot find -lsolver-lz?!! 10/08 19:59
8F:→ ric2k1:-lsolver-lz 不要黏在一起... 10/08 20:11
9F:推 newmilktea:喔喔!!謝謝教授! 10/08 20:16
10F:→ ric2k1:不客氣! 可以推個 ID 對照表嗎? (目前尚未過半...) 10/08 21:43