[問題] gcc link .lib 的問題(已爬文)

看板C_and_CPP作者 (該睡了...眠吧)時間14年前 (2009/11/19 03:57), 編輯推噓0(0010)
留言10則, 3人參與, 最新討論串1/1
遇到的問題: (題意請描述清楚) 小弟目前手邊有一個由 Voiceage 所提供的 AMR library, 在他的公司網站可以下載得到 http://www.voiceage.com/media/AMR-NB.zip 裡面有包含 .lib .h 及 範例檔 希望能於自己的程式中引用他所提供的 encoder/decoder 函式 但由於是 .lib 檔,所以不知如何引用 有嘗試過 reimp 及 dlltool 試圖將其轉為 .def 、 .dll 但由 reimp 轉出來的檔案不正確(非 .def 檔) 希望得到的正確結果: 能夠正確的 link AMR library 程式跑出來的錯誤結果: Info: resolving __iob by linking to __imp___iob (auto-import) Warning: .drectve `-defaultlib:LIBC ' unrecognized Warning: .drectve `-defaultlib:OLDNAMES ' unrecognized Warning: .drectve `-defaultlib:LIBC ' unrecognized Warning: .drectve `-defaultlib:OLDNAMES ' unrecognized Warning: .drectve `-defaultlib:LIBC ' unrecognized Warning: .drectve `-defaultlib:OLDNAMES ' unrecognized Warning: .drectve `-defaultlib:LIBC ' unrecognized Warning: .drectve `-defaultlib:OLDNAMES ' unrecognized ../../Voiceage_AMR-NB//AMR-NB.lib(./Release/sp_enc.obj):C:\Claude\Data\3GP:(.text[_code_2i40_9bits]+0x6): undefined reference to `_chkstk' ../../Voiceage_AMR-NB//AMR-NB.lib(./Release/sp_enc.obj):C:\Claude\Data\3GP:(.text[_code_2i40_11bits]+0x6): undefined reference to `_chkstk' ../../Voiceage_AMR-NB//AMR-NB.lib(./Release/sp_enc.obj):C:\Claude\Data\3GP:(.text[_code_3i40_14bits]+0x6): undefined reference to `_chkstk' ../../Voiceage_AMR-NB//AMR-NB.lib(./Release/sp_enc.obj):C:\Claude\Data\3GP:(.text[_code_4i40_17bits]+0x6): undefined reference to `_chkstk' ../../Voiceage_AMR-NB//AMR-NB.lib(./Release/sp_enc.obj):C:\Claude\Data\3GP:(.text[_code_8i40_31bits]+0x6): undefined reference to `_chkstk' ../../Voiceage_AMR-NB//AMR-NB.lib(./Release/sp_enc.obj):C:\Claude\Data\3GP:(.text[_code_10i40_35bits]+0x6): more undefined references to `_chkstk' follow fu000001.o:(.idata$2+0xc): undefined reference to `libmsvcrt_a_iname' fu000004.o:(.idata$2+0xc): undefined reference to `libmsvcrt_a_iname' fu000006.o:(.idata$2+0xc): undefined reference to `libmsvcrt_a_iname' fu000008.o:(.idata$2+0xc): undefined reference to `libmsvcrt_a_iname' fu000010.o:(.idata$2+0xc): undefined reference to `libmsvcrt_a_iname' fu000012.o:(.idata$2+0xc): more undefined references to `libmsvcrt_a_iname' follow nmth000000.o:(.idata$4+0x0): undefined reference to `_nm___iob' collect2: ld returned 1 exit status make: *** [waveMaker.exe] Error 1 開發平台: (例: VC++ or gcc/g++ or Dev-C++, Windows or Linux) mingw+gcc 3.4.5 有問題的code: (請善用置底文標色功能) Library 名稱/位置: Voiceage_AMR-NB/AMR-NB.lib 於 makefile 中: -L"Voiceage_AMR-NB/" -lAMR-NB 補充說明: 有嘗試過 reimp 及 dlltool 試圖將其轉為 .def 、 .dll 但由 reimp 轉出來的檔案不正確(非 .def 檔) 懇求各路大神解答 m(_ _)m -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 61.224.51.65

11/19 14:40, , 1F
我只知道gcc的lib格式檔名為lib[名稱].a
11/19 14:40, 1F

11/19 14:42, , 2F
.lib是不是visual c++用的?
11/19 14:42, 2F

11/19 15:54, , 3F
VC 應該是加入 dependencies 吧,印象中沒有很明確寫成
11/19 15:54, 3F

11/19 15:54, , 4F
static link 的欄位。
11/19 15:54, 4F

11/19 15:55, , 5F
而且一看到 libmscvrt 就會聯想到 MS VC Runtime,你用其
11/19 15:55, 5F

11/19 15:56, , 6F
它的編譯環境應該還要多 link 什麼才對,而且不曉得
11/19 15:56, 6F

11/19 15:56, , 7F
calling convention 有沒有通。
11/19 15:56, 7F

11/19 15:57, , 8F
我沒在 win 上寫程式,只能猜到這樣。
11/19 15:57, 8F

11/19 23:43, , 9F
看起來好像除了用VC外 沒有特別的方法...?
11/19 23:43, 9F

11/19 23:43, , 10F
還是謝謝樓上們的指教 :)
11/19 23:43, 10F
文章代碼(AID): #1B1577WU (C_and_CPP)