編譯faac時遇到了以下的編譯錯誤:
/home/xuxuequan/Ingenicwork/toolchain/mips-gcc472-glibc216-32bit/mips-linux-gnu/libc/usr/include/string.h:365:26: error:ambiguates old declaration 'const char* strcasestr(const char*, const char*)'
解決方案:
在文件 /common/mp4v2/mpeg4ip.h ?line 126注釋掉如下語句即可:
126 //char *strcasestr(const char *haystack, const char *needle);
原因分析:
根本原因好像是函數strcasestr的聲明與在toolchain string.h沖突了,所以導致發生了錯誤。基于這個原因也可以按照如下方式修改:
從123行開始修改此文件mpeg4ip.h,到129行結束。
修改前:
#ifdef?__cplusplus
extern?"C"?{
#endif
char?*strcasestr(const?char?*haystack,?const?char?*needle);
#ifdef?__cplusplus
}
#endif
修改后:
#ifdef?__cplusplus
extern?"C++"?{
#endif
const?char?*strcasestr(const?char?*haystack,?const?char?*needle);
#ifdef?__cplusplus
}
#endif
#define _GNU_SOURCE
#include <string.h>
char *strcasestr(const char *haystack, const char *needle);
用于在c串haystack中查找c串needle,忽略大小寫。如果找到則返回needle串在haystack串中第一次出現的位置的char指針
在實際的應用中如果只加上頭文件,當編譯時會出現 ?warning: assignment makes pointer from integer without a cast
這是因為函數的聲明在調用之后。未經聲明的函數默認返回int型。
因此要在#include所有頭文件之前加 ?#define _GNU_SOURCE ?,以此解決此問題。