The resolution of undefined reference to ' strstr ' error occurred in porting uip-0.9 to U-boot

Source: Internet
Author: User
Tags strlen

I want to Port Peep2k's web failsafe http to mt7620 Uboot, but there is an error undefined reference to ' strstr '.



The console output is as follows:

NET/LIBNET.A (HTTPD.O): in function ' Httpd_findandstore_firstchunk ':
uip-0.9/httpd.c: (. text+0x90): undefined Reference to ' Strstr '
uip-0.9/httpd.c: (. text+0xa8): Undefined reference to ' strstr '
uip-0.9/httpd.c: (. text+ 0xd4): Undefined reference to ' strstr '
uip-0.9/httpd.c: (. text+0x108): Undefined reference to ' strstr '
uip-0.9/ HTTPD.C: (. text+0x14c): Undefined reference to ' strstr '

Analysis:

This error is in the link stage, stating that the method that provides the STRSTR function is not eventually compiled into the target file. Obviously, the STRSTR function appears in the STRING.C source file, where is the problem.


Then opened the string.c file, found the mystery.

#ifndef __have_arch_strstr
/**
 * Strstr-find the first substring in a%nul terminated string
 * @s1: The Stri ng to is searched
 * @s2: The string to search for
 *
/char * STRSTR (const char * s1,const char * s2)
{
	int L1, L2;

	L2 = strlen (s2);
	if (!L2)
		return (char *) s1;
	L1 = strlen (S1);
	while (L1 >= L2) {
		l1--;
		if (!memcmp (S1,S2,L2))
			return (char *) s1;
		s1++;
	}
	return NULL;
}
#endif
#ifndef __HAVE_ARCH_STRSTR
If __HAVE_ARCH_STRSTR is not defined, the STRSTR is compiled. Look at the front of the file on the definition of the macro, it will be enlightened.

/* In the order to save flash space, we declare below the definition here.
 * Please modify the IT if you need below function */
#define __HAVE_ARCH_STRNICMP
#define __HAVE_ARCH_STRNICMP
#d Efine __have_arch_strcpy
#define __HAVE_ARCH_STRNCPY
#define __HAVE_ARCH_STRCAT
#define __have_arch_ Strncat
#define __HAVE_ARCH_STRCMP
#define __HAVE_ARCH_STRNCMP
#define __HAVE_ARCH_STRDUP
# Define __HAVE_ARCH_STRSPN
#define __HAVE_ARCH_STRPBRK
#define __HAVE_ARCH_STRTOK
#define __have_ Arch_strsep
#define __HAVE_ARCH_STRSWAB
#define __HAVE_ARCH_BCOPY
#define __have_arch_memscan
#define __HAVE_ARCH_STRSTR
#define __HAVE_ARCH_MEMCHR

Look at the English comments above, you should understand what is going on, comment out the corresponding macro can be.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.