对stricmp的未定义引用

我正在尝试创建一个方法来查找并替换字符串中的字符串,但我似乎在编译时遇到了一些错误。 我能找到一些帮助来弄清楚发生了什么吗?

void replaceString(char *find, char *replace) { int len_string,i; char temp[30]; len_string=strlen(find); while(1) { for(i=0;i<len_string;i++) temp[i]=fgetc(edit); temp[i+1]=NULL; /* the stricmp() is used for comparing both string. */ if(stricmp(find,temp)==0) { fprintf(edit,"%s ",replace); fclose(edit); exit(1); } fseek(edit,-(len_string-1),1); } } 

我在编译时获得的错误是对stricmp的未定义引用。 我知道这不是正确的编码约定,但编辑(FILE类型的对象)当前是一个全局变量。

stricmp是特定于Windows的。 如果你不在Windows上, strcasecmp

实际上,错误是在链接时而不是在编译时。 您的代码被编译为一个目标文件,期望在与其他无法找到的目标文件链接时查找stricmp的实现。 因此错误:“对stricmp的未定义引用”。 正如bmargulies指出的那样,该实现仅在Windows库中可用。 如果您使用的是POSIX兼容系统,则可以切换到strcasecmp()。