2014-02-21 54 views
0

如何正確鏈接靜態庫到Netbeans項目中?Netbeans:將靜態庫鏈接到項目

我試圖建立在FreeBSD我的應用程序 - 我得到了u和我的媒體庫的.h文件(該庫是魔鬼圖形庫BTW)

我已經加入了包括目錄在圖書館:

File => Project Properties => Build => C++ Compiler => General => Include Directories

然後,根據File => Project Properties => Build => Linkers => Libraries加入我的圖書館作爲一個文件:../../../source/devil/libIL.a

然而,當我編譯它,我得到以下錯誤:

No rule to make target ../../../source/devil/libIL.a

(我自己也嘗試在庫路徑乞討的接頭庫添加-static標誌。

+0

你嘗試添加一個額外的lib'dir'(不僅是LIB本身)找到圖書館@'屬性 - >建設 - > Linker'?其他鏡頭,嘗試在鏈接器添加選項字段中添加'-lIL'。 –

+0

是的,我也嘗試添加庫目錄路徑。關於Linker附加選項中的'-lIL'選項,我得到以下錯誤:'/ usr/local/bin/ld:找不到-lIL'。 – Lucas

+0

對不起,我的意思是兩個選項,所以'-lLD'應該在lib目錄之後的'libIL.a'看起來應該是精確的。 –

回答

0

在Ubuntu,則params間接發送到裝載機必須-Wl,前面,作爲LD的手冊(man ld)中指出:

Note---if the linker is being invoked indirectly, via a compiler driver (e.g. gcc) then all the linker command line options should be prefixed by -Wl, (or whatever is appropriate for the particular compiler driver) like this: gcc -Wl,--start-group foo.o bar.o -Wl,--end-group

的NetBeans使用在「添加選項...」按鈕庫菜單(項目屬性>鏈接>庫),這樣做:

Screenshot of Netbeans libraries menu

在以前的形象,我用-Wl,-static所有以前的庫靜態鏈接。

乾杯,