[英]Netbeans: linking static library to the project
How can I properly link the static library into the Netbeans project? 如何正确地将静态库链接到Netbeans项目?
I am trying to build my app on the FreeBSD - I got the .a and the .h files of my library (the library is the devil graphic library btw.) 我试图在FreeBSD上构建我的应用程序-我得到了我的库的.a和.h文件(该库是魔鬼图形库btw。)
I have added the include directory for the library in the: 我在以下位置添加了该库的包含目录:
File => Project Properties => Build => C++ Compiler => General => Include Directories
then, under the File => Project Properties => Build => Linkers => Libraries
added my library as a file: ../../../source/devil/libIL.a
然后,在
File => Project Properties => Build => Linkers => Libraries
将我的库添加为文件: ../../../source/devil/libIL.a
However, when I am compiling it I get the following error: 但是,当我编译它时,出现以下错误:
No rule to make target ../../../source/devil/libIL.a
(I have also tried to add the -static
flag at the begging of the library path in the linkers libraries. (我还尝试过在链接器库中的库路径
-static
添加-static
标志。
On Ubuntu, params indirectly sent to the loader must be preceded with -Wl,
, as stated in the manual of ld ( man ld
): 在Ubuntu上,如ld(
man ld
)手册中所述,间接发送到加载程序的参数必须以-Wl,
man ld
:
Note---if the linker is being invoked indirectly, via a compiler driver (eg 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
注-如果链接器是通过编译器驱动程序(例如gcc)间接调用的,则所有链接器命令行选项都应以-Wl(或适用于特定编译器驱动程序的前缀)为前缀,例如:
gcc -Wl,--start-group foo.o bar.o -Wl,--end-group
On Netbeans use the "Add Option..." button in the libraries menu (Project Properties > Linker > Libraries) to do so: 在Netbeans上,使用库菜单(“项目属性”>“链接器”>“库”)中的“添加选项...”按钮执行以下操作:
In the previous image, I've used -Wl,-static
to link all of the previous libraries statically. 在上一个图像中,我使用
-Wl,-static
静态链接了所有先前的库。
Cheers, 干杯,
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.