tomKPZ
tomKPZ

Reputation: 837

How to link to libraries using gcc

I installed some encryption software called libntru. The header files are installed in /usr/include/libntru and the file I would like to include from this directory is ntru.h. The compiled library is installed to /usr/lib/libntru.so.

In my makefile, I use gcc's -L and -l flags to link to the library as such -L/usr/lib -lntru, however in my project, I get a compiler error at the line #include <ntru.h>.

How can I link to this library? Thanks in advance for any help.

Upvotes: 0

Views: 130

Answers (1)

Jonathan Leffler
Jonathan Leffler

Reputation: 753455

Check on the instructions with the software; there's at least a chance you're supposed to write one of:

#include <libntru/ntru.h>
#include "libntru/ntru.h"

If that's the case, you won't need to specify anything on the command line to find the headers (no -I option). If you're supposed to write just:

#include <ntru.h>
#include "ntru.h"

Then you need to add -I/usr/include/libntru to the command line.

Note that you probably don't need -L/usr/lib on the command line; the compiler will normally look there anyway, but you will need the -lntru option to specify the library itself, of course.

Upvotes: 4

Related Questions