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

  • 1
    man strlcpy will display their man page. If you're having problems with your code, you need to post the code, post the compiler command line, and do it on Stack Overflow since programming questions are off-topic here. – Gilles 'SO- stop being evil' Sep 20 '15 at 23:50
  • 1
    strlcpy() and similar are available in libc on most UNIX variants. Linux is an exception as a former glibc maintainer did not like them even though he was not able to explain why or to point to a better concept. Software that ports to Linux usually implements own versions of these functions. – schily Sep 21 '15 at 11:11

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.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.