VC下编译libMPG123(补)

前次用VC编译了libMPG123库,编译通过,但是没有进行例子程序编译测试。今天测试了一下用libMPG123做MP3到WAV的解码,结果编译器连接错误,提示找不到符号 _strcasecmp 和 _strncasecmp。使用google大法,发现VC没有strcasecmp和strncasecmp函数,只好为他做了一个补丁。

在.h文文件中添加如下声明:

#ifdef _MSC_VER
int strcasecmp(char *s1, char *s2);
int strncasecmp(char *s1, char *s2, register int n);
#endif

在.c文件中添加如下实现

#ifdef _MSC_VER
int strcasecmp(char *s1, char *s2)
{
   while  (toupper((unsigned char)*s1) == toupper((unsigned char)*s2++))
       if (*s1++ == '') return 0;
   return(toupper((unsigned char)*s1) - toupper((unsigned char)*--s2));
}

int strncasecmp(char *s1, char *s2, register int n)
{
  while (--n >= 0 && toupper((unsigned char)*s1) == toupper((unsigned char)*s2++))
      if (*s1++ == '')  return 0;
  return(n < 0 ? 0 : toupper((unsigned char)*s1) - toupper((unsigned char)*--s2));
}
#endif

编译连接通过。

Popularity: 2% [?]

Related

Comments

8 Responses to “VC下编译libMPG123(补)”

  1. Blur on June 17th, 2008 4:43 pm

    自己动手 丰衣足食 :)

    [Reply]

  2. tail on June 20th, 2008 11:27 am

    我在使用libmpg123的dll时候出现
    错误的签名
    AppName:1.exe AppVer: 0.0.0.0 ModName: libmpg123-0.dll
    ModVer: 0.0.0.0 Offset: 00025025
    楼主有遇到过吗?

    [Reply]

  3. sunny on June 20th, 2008 7:09 pm

    没有碰到你说的这个问题。

    [Reply]

  4. lfp001 on September 6th, 2008 10:44 am

    中有这两个函数,只是函数名称不同,功能是相同的.

    #ifdef _MSC_VER
    #define strcasecmp stricmp
    #define strnicmp strncasecmp
    #endif

    [Reply]

  5. lfp001 on September 6th, 2008 10:55 am

    VC下编译libmpg123涉及的问题可能不止这些吧?我从mpg123 的0.59版本开始就下载源码用于自己的解码程序,现在最新版本是1.5.1,变化挺大的.要将优秀的MP3解码核心用于Windows有很多地方都得略作修改,以发挥其性能.我看过很多Linux下的MP3解码核心,对MPG123情有独钟.希望楼主留下联系方式讨论一下.

    [Reply]

  6. lfp001 on September 6th, 2008 11:02 am

    vc的string.h中有两个函数stricmp和strnicmp,函数名称不同,对应的功能是相同的.

    在config.h中加入心下两行就可以了:
    #define strcasecmp stricmp
    #define strncasecmp strnicmp

    [Reply]

    sunny Reply:

    恩,这个方法好

    [Reply]

  7. Articles about _strcasecmp volume 1 « Article Directory on June 15th, 2010 11:51 am

    [...] VC下编译libMPG123(补) : sunnyu 前次用VC编译了libMPG123库,编译通过,但是没有进行例子程序编译测试。 今天测试了一下用libMPG123做MP3到WAV的解码,结果编译器连接错误,提示找不到符号 _strcasecmp 和 _strncasecmp。 使用google大法,发现VC没有strcasecmp和strncasecmp函数,只好为他做了一个补丁。 … [...]