Ava
Ava

Reputation: 838

Linking unistd.h when using CC compiler (Solaris)

I need to link <unistd.h> in my program using CC compiler on Solaris. When I needed to link <math.h> or <curses.h> I just used Google to find -lm and -lcurses flags but this time Google didn't help. How to find out in which lib*something* is <unistd.h> located?

Upvotes: 1

Views: 1935

Answers (1)

dbush
dbush

Reputation: 223972

For any given function, the man page tells you both what headers to include and what libraries to link.

For example, the ceil function:

Synopsis

c99 [ flag... ] file... -lm [ library... ]
#include <math.h>

double ceil(double x);

float ceilf(float x);

long double ceill(long double x);

It tells you to #include <math.h> and to link with -lm.

Most functions declared in <unistd.h> don't require any additional libraries to link in, but when in doubt check the man pages.

Upvotes: 3

Related Questions