Re: [問題] GCC初學疑慮: 添加新的函式庫
先謝謝版友們的提示:
→
04/01 14:13,
04/01 14:13
但是先前在編譯時曾經有加入參數-I -L
這裡使用idconfig的用意為何? 這兩種方式網頁的說明不都是去指定路徑嗎?
→
04/02 00:29,
04/02 00:29
也有其他人建議以下指令:
gcc -static test.c -L/mnt/test/libusb-1.0.9/install -lusb-1.0
/usr/lib/gcc/i486-linux-gnu/4.4.3/../../../../lib/libusb-1.0.a
(libusb_1_0_la-core.o):
In function `libusb_set_interface_alt_setting':
/mnt/test/libusb-1.0.9/libusb/core.c:1387: undefined reference to
`pthread_mutex_lock'
/mnt/test/libusb-1.0.9/libusb/core.c:1392: undefined reference to
`pthread_mutex_unlock'
/mnt/test/libusb-1.0.9/libusb/core.c:1389: undefined reference to
`pthread_mutex_unlock'
....後面還有很多省略
提示告訴我libusb-1.0.9這東西本身也有問題,
自己都找不到參考對象了自然不能給人參考
一直到輸入以下指令, 才成功編譯出a.out
gcc -static test.c -L/mnt/test/libusb-1.0.9/install -lusb-1.0 -lpthread -lrt
這裡有三個疑問:
首先這裡為何要使用 -static?
是否官網的壓縮檔沒有包含完整的東西, 以後我要下載其他組件或函式庫, 都要這樣
東拉拉西拉拉嗎?
感覺這樣我的函式庫最後不是會很亂很不利嗎?
最後一個問題我自己再上網學一下, 就是為啥人家一眼就看到那些找不到的參考對象就知
道要 -lpthread 跟 -lrt?
好像是利用objdump去找
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 59.120.179.30
→
04/02 10:13, , 1F
04/02 10:13, 1F
→
04/02 10:14, , 2F
04/02 10:14, 2F
討論串 (同標題文章)
C_and_CPP 近期熱門文章
PTT數位生活區 即時熱門文章