Undefined reference to 'strnlen' even though "string.h" includes
I am trying to use create a project for LPC1769 on LPCXpresso. I have a C file calling
#include <string.h>
int main()
{
//some stuff
strnlen(SomeString, someInt);
}
to which I get the error:
Undefined reference to 'strnlen'
The weird part is that there is no problem with strcpy, strncpy, or any other normal string functions.
I am building a Cortex-M3 processor Compiler used: arm-none-eabi-gcc In Eclipse I checked the MCU linker option: No bootable or standard libs I am running Eclipse on Ubuntu
While it might be easy enough to get around this by just using strlen, I am really running into a problem using a library that uses strnlen and I don't want to link to the library source.
source to share
The function strnlen
was (until recently) a Linux-specific function (some documents, such as the GNU libc manual , still say it is a "GNU extension"). The current man page says it is part of POSIX.1-2008. Since you are cross-compiling, it is possible that the target computer's runtime library does not have this functionality. A 2011 forum post said just that.
source to share