我已经在我的 Ubuntu 上下载并安装了 NTL 库。我目前正在使用 gedit 编写我的程序,并在我的程序中包含此 ZZ.h
header 。这就是我在终端中编译程序的方式: - g++ keygen.cpp -o keygen -I ../include -L ../lib -lntl -lm
.
我很确定这条线是正确的,但由于某种未知的原因,我收到以下错误:
KeyGen.cpp:9:20: error: NTL/ZZ.h: No such file or directory
KeyGen.cpp:15: error: expected constructor, destructor, or type conversion before ‘int’
解决方案对我来说似乎非常简单:即将 NTL 库直接添加到我的程序文件夹中。我就是这样做的,但仍然遇到同样的错误。
最佳答案
如果您不需要最新(6.0.0)版本的 NTL,您可以在 Ubuntu 中执行以下操作:
user@host:~$ sudo apt-get install libntl-dev Reading package lists... Done Building dependency tree Reading state information... Done The following extra packages will be installed: libntl-5.4.2 The following NEW packages will be installed: libntl-5.4.2 libntl-dev 0 upgraded, 2 newly installed, 0 to remove and 112 not upgraded. Need to get 2,035 kB of archives. After this operation, 7,016 kB of additional disk space will be used. Do you want to continue [Y/n]? y Get:1 http://ftp.de.debian.org/debian/ squeeze/main libntl-5.4.2 amd64 5.4.2-4 [767 kB] Get:2 http://ftp.de.debian.org/debian/ squeeze/main libntl-dev amd64 5.4.2-4 [1,268 kB] Fetched 2,035 kB in 2s (1,017 kB/s) Selecting previously deselected package libntl-5.4.2. (Reading database ... 59184 files and directories currently installed.) Unpacking libntl-5.4.2 (from .../libntl-5.4.2_5.4.2-4_amd64.deb) ... Selecting previously deselected package libntl-dev. Unpacking libntl-dev (from .../libntl-dev_5.4.2-4_amd64.deb) ... Can not write log, openpty() failed (/dev/pts not mounted?) Setting up libntl-5.4.2 (5.4.2-4) ... Setting up libntl-dev (5.4.2-4) .. user@host:~$
之后,包含所有开发头文件的完整编译 NTL 库将安装在您的系统中,您可以使用它编译您的程序,而无需任何额外的 -I
如果您需要发行版具有的更新版本(检查 http://packages.ubuntu.com/en/source/trusty/ntl ),您可以尝试自己构建库包。
关于c++ - 未找到 NTL 头文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21457079/