C / C ++:如何找出链接标志? [英] C/C++: how to figure out link flags?
本文介绍了C / C ++:如何找出链接标志?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我如何可靠地找出链接标志库?我总是最后使用Google /挖手册。
How do I reliably figure out link flags for libraries? I always end up googling/digging manuals.
有没有办法列出可用于链接库,其名称和/或说明?
Is there a way to list libraries available for linking, with names and/or descriptions?
编辑:Linux系统,GNU编译链,经典
edit: Linux system, GNU build chain, classics.
推荐答案
在大多数Linux系统,你可以使用的 pkg配置
,列出一个给定库的编译器选项。例如:
On most Linux systems, you can use pkg-config
to list out the compiler options for a given library. For example:
g++ example.cpp $(pkg-config --cflags --libs libpng)
变为
g++ example.cpp -I/usr/include/libpng12 -lpng12
或例如使用稍微复杂的输出:
Or an example with slightly more complicated output:
$ pkg-config --cflags --libs gthread
-D_REENTRANT -I/usr/include/glib-1.2 -I/usr/lib64/glib/include -lgthread -lpthread -lglib
这篇关于C / C ++:如何找出链接标志?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文