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?
Asked
Active
Viewed 1,513 times
1

Antti Haapala -- Слава Україні
- 129,958
- 22
- 279
- 321

Ava
- 818
- 10
- 18
-
1`
` is a header that is included. It is not linked in. Neither is a ` – Antti Haapala -- Слава Україні Dec 23 '17 at 22:51` **in** the `libm`; it just *describes its contents*. -
the functions exposed by `unistd.h` are all contained in the `libc.so` library, which is always linked in, so nothing has to be done at link time (unlike the libcurses.so and libmath.so libraries.) – user3629249 Dec 24 '17 at 04:26
1 Answers
3
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.

Jonathan Leffler
- 730,956
- 141
- 904
- 1,278

dbush
- 205,898
- 23
- 218
- 273