Search code examples
c++cygwinshared-librariesntl

How to install and use NTL in cygwin


The libraries that I've used so far require installation. So they generate xx.a file that can be included in the code in cygwin. However, NTL library for windows only requires to unzip the file. So I need to know how to use it in cygwin command line. I have done #include in the code. The problem is in include directory in NTL all files are " .h".

What I have done is:

g++  -c  Polynomial.cpp -L/cygdrive/c/cygwin/home/Win7/libpaillier -  
l:libpaillier.a -L/cygdrive/c/cygwin/home/Win7/Cryptopp -l:libcryptopp.a   -
L/cygdrive/c/cygwin/home/Win7/WinNTL-9_2_0/include/NTL -lgmpxx -lgmp

but I get below error:

fatal error: NTL/ZZ.h: No such file or directory
#include <NTL/ZZ.h>
                ^
compilation terminated.

It'd be great if someone give me a clue. TBC: I have already installed GMP and been using it.


Solution

  • In gcc path to headers location is specified with -I switch. With -L you define paths to compiled libraries location (directories with .a or .so files).

    Also if full path to zz.h is /cygdrive/c/cygwin/home/Win7/WinNTL-9_2_0/include/NTL/zz.h then NTL should not be included in path specified in gcc arguments.

    So, you need at least to replace

    -L/cygdrive/c/cygwin/home/Win7/WinNTL-9_2_0/include/NTL
    

    with

    -I/cygdrive/c/cygwin/home/Win7/WinNTL-9_2_0/include
    

    and maybe for others libraries as well and add paths to compiled libraries locations with -L where they are needed.