简体   繁体   English

如何包含外部库?

[英]How to include external library?

Hi i would like to include a external library call NTL. 嗨,我想包括一个外部库调用NTL。 its in the path as followed: 其路径如下:

#include "WinNTL-5_4_2/include/NTL/tools.h"

My file is key.cpp and its reside in the same folder as NTL . 我的文件是key.cpp,它与NTL驻留在同一文件夹中。 but when i compile, it came up with another error which is .. 但是当我编译时,它又出现了另一个错误,即..

In file included from keygen.cpp:6:0:
WinNTL-5_4_2/include/NTL/tools.h:5:24: fatal error: NTL/ctools.h: No such file or directory
compilation terminated.

As its need another file call ctools.h, how do i includes tools.h to make ctools.h work also 由于需要另一个文件调用ctools.h,我如何包含tools.h以使ctools.h也能工作

I tried type 我尝试过打字

me@ubuntu:~/GG$ g++ keygen.cpp -o keygen -l WinNTL-5_4_2/include/
keygen.cpp:6:23: fatal error: NTL/tools.h: No such file or directory

but it doesnt work still. 但它仍然无法正常工作。

Based on the error message, you should try changing your include to: 根据错误消息,您应该尝试将include更改为:

#include "NTL/tools.h"

and make sure that WinNTL-5_4_2/include is in your compiler's search path for include files. 并确保WinNTL-5_4_2/include在编译器的包含文件搜索路径中。

You need to add the root directory as part of your project's search path for include files. 您需要将根目录添加为项目包含文件搜索路径的一部分。 It depends on your environment exactly how to do this, but there are usually two search paths -- one for include files and another for compiled libraries. 具体取决于您的环境如何执行此操作,但是通常有两个搜索路径-一个用于包含文件,另一个用于已编译库。 Set that with the directory that contains the WinNTL-5_4_2 directory and you should be golden. 使用包含WinNTL-5_4_2目录的目录进行设置,您应该会很高兴。

您必须在编译器的包含路径中添加“ fullpath / WinNTL-5_4_2 / include”(通过-I表示gcc或在Visual Studio项目的包含路径列表中)期望ctools.h存在于“ ...”中。 / WinNTL-5_4_2 / include / NTL”

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM