如何在g ++中包含库的路径 [英] How do I include a path to libraries in g++
问题描述
我试图在我的makefile中包含额外库的路径,但我无法弄清楚如何让编译器使用该路径。到目前为止,我有:
g ++ -g -Wall testing.cpp fileparameters.cpp main.cpp -o test
我想包含 $ b $
/ data [...] / lib
因为tests.cpp包含来自该库的文件。另外,我在一台linux机器上。
编辑:不是库的路径。只是包含的文件。我的不好。
要指定要搜索(二进制)库的目录,只需使用 - L
:
-L / data [...] / lib
code>
要指定实际的库名称,可以使用 -l </ code>: p>
-lfoo#(链接libfoo.a或libfoo.so)
$ b 要指定一个目录来搜索 include 文件(与库不同!),可以使用 -I $ c
-I / data [...] / lib
所以我想你想要的是类似于
g ++ -g -Wall -I / data [...] / lib testing.cpp fileparameters.cpp main.cpp -o test
I am trying to include the path to extra libraries in my makefile, but I can't figure out how to get the compiler to use that path. so far I have:
g++ -g -Wall testing.cpp fileparameters.cpp main.cpp -o test
and I want to include the path to
/data[...]/lib
because testing.cpp includes files from that library. Also, I'm on a linux machine.
EDIT: Not a path to a library. Just to files that were included. My bad.
解决方案To specify a directory to search for (binary) libraries, you just use
-L
:-L/data[...]/lib
To specify the actual library name, you use
-l
:-lfoo # (links libfoo.a or libfoo.so)
To specify a directory to search for include files (different from libraries!) you use
-I
:-I/data[...]/lib
So I think what you want is something like
g++ -g -Wall -I/data[...]/lib testing.cpp fileparameters.cpp main.cpp -o test
这篇关于如何在g ++中包含库的路径的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!