Implicit declaration of strlcpy and strlcat even with “string.h” included

man

Gcc throws an error when I try to call the functions strlcpy or strlcat in a C file:

error : implicit declaration of strlcpy
error : implicit declaration of strlcat

In what library can I find those functions, and their man page? I included string.h but it doesn't change anything. I'm running Linux Mint 17.2 and gcc 4.8.4

Best Answer

On Ubuntu, Mint, and relatives, strlcpy and strlcat are available in the libbsd-dev package. Run

sudo apt-get install libbsd-dev

This will install the libraries, header files, and man pages.

To use the functions from C code, add the line

#include <bsd/string.h>

to your files, and add -lbsd , or the more portable $(pkg-config --libs libbsd) , to your gcc command line to link the library.

Related Question