我如何在G+&#x2B中包含通往库的路径。
我正在尝试将额外库的路径包括在我的makefile中,但是我不知道如何让编译器使用该路径。到目前为止,
g++ -g -Wall testing.cpp fileparameters.cpp main.cpp -o test
我想包括通往的路径
/data[...]/lib
,因为testing.cpp
包括该库中的文件。另外,我在Linux机器上。
编辑:不是通往库的路径。仅来自该库中的标题文件。我的坏。
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 header files from that library that were included. My bad.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
要指定一个目录以搜索(二进制)库,您只需使用
-L
:要指定实际库名称,您就可以使用
-L
:为搜索指定目录对于 include 文件(与库不同!),您使用
-i
:所以我认为您想要的是类似
这些编译器标志的东西(其他)也可以在GNU GCC命令选项手册:
To specify a directory to search for (binary) libraries, you just use
-L
:To specify the actual library name, you use
-l
:To specify a directory to search for include files (different from libraries!) you use
-I
:So I think what you want is something like
These compiler flags (amongst others) can also be found at the GNU GCC Command Options manual:
在您的makefile或cmakelists.txt中,您可以设置CMAKE_CXX_FLAGS如下:
In your MakeFile or CMakeLists.txt you can set CMAKE_CXX_FLAGS as below:
另外,您可以设置环境变量。
假设您正在使用
bash
,然后在〜/.bashrc
中使用
source〜/.bashrc
编写和源。你应该很好。
Alternatively you could setup environment variables.
Suppose you are using
bash
, then in~/.bashrc
, writeand source it with
source ~/.bashrc
.You should be good to go.