Newsgroup: it.comp.lang.c
Titolo: Problema di linkaggio

Salve ho il seguente listato:
-----------------------------------------------
#include <stdio.h>
#include <stdlib.h>
#include <sndfile.h>
int LoadSoundFile(char *filename, unsigned int *rate, unsigned int *channels,
                  unsigned int *bits, u_int8_t **buf, unsigned int *buflen)
{
    SNDFILE *file;
    SF_INFO file_info;
    short *buffer_short = NULL;
    u_int8_t *buffer_8 = NULL;
    int16_t *buffer_16 = NULL;
    unsigned int i;
    file = sf_open_read(filename, &file_info);
    if (file == NULL)
    {
      printf("Unable to open '%s'.\n", filename);
      return -1;
    }
    if ((file_info.format & 0x0F) != SF_FORMAT_PCM)
    {
      printf("'%s' is not a PCM-based audio file.\n", filename);
      sf_close(file);
      return -1;
    }
    if ((file_info.pcmbitwidth != 8) && (file_info.pcmbitwidth != 16))
    {
      printf("'%s' uses an unrecognized sample size.\n", filename);
      sf_close(file);
      return -1;
    }
    buffer_short = (short *)malloc(file_info.samples * file_info.channels * sizeof (short));
    buffer_8 = (u_int8_t *)malloc(file_info.samples * file_info.channels * file_info.pcmbitwidth / 8);
    buffer_16 = (int16_t *)buffer_8;
    if (buffer_short == NULL || buffer_8 == NULL)
    {
      printf("Unable to allocate enough memory for '%s'.\n", filename);
      fclose(file);
      free(buffer_short);
      free(buffer_8);
      return -1;
    }
    if (sf_readf_short(file,buffer_short,file_info.samples) == (size_t)-1)
    {
      printf("Error while reading samples from '%s'.\n", filename);
      fclose(file);
      free(buffer_short);
      free(buffer_8);
      return -1;
    }
    for (i = 0; i < file_info.samples * file_info.channels; i++)
    {
      if (file_info.pcmbitwidth == 8)
      {
        buffer_8[i] = (u_int8_t)((short)buffer_short[i] + 128);
      }
      else
      {
        buffer_16[i] = (int16_t)buffer_short[i];
      }
    }
    *rate = file_info.samplerate;
    *channels = file_info.channels;
    *bits = file_info.pcmbitwidth;
    *buf = buffer_8;
    *buflen = file_info.samples * file_info.channels * file_info.pcmbitwidth / 8;
    sf_close(file);
    free(buffer_short);
    return 0;
}
------------------------------------------------
provando a compilare ho i seguenti errori:
gcc -Wall mp-loadsound.c -o mp-loadsound
/usr/lib/crt1.o(.text+0x18): In function `_start':
: undefined reference to `main'
/tmp/ccN5cXaA.o(.text+0x28): In function `LoadSoundFile':
: undefined reference to `sf_open_read'
/tmp/ccN5cXaA.o(.text+0x7f): In function `LoadSoundFile':
: undefined reference to `sf_close'
/tmp/ccN5cXaA.o(.text+0xb8): In function `LoadSoundFile':
: undefined reference to `sf_close'
/tmp/ccN5cXaA.o(.text+0x180): In function `LoadSoundFile':
: undefined reference to `sf_readf_short'
/tmp/ccN5cXaA.o(.text+0x275): In function `LoadSoundFile':
: undefined reference to `sf_close'
collect2: ld returned 1 exit status
qualcuno sa aiutarmi?
grazie

  grazie
comunque queste domande le dovresti fare su it.comp.os.linux.development ...
questo non e' ANSI C ...
ciao ...
-- 
#include <stdio.h>
int main(void){char c[]={10,65,110,116,111,110,105,111,32,98,97,114,98,111,110,
101,32,60,104,105,110,100,101,109,105,116,64,116,105,115,99,97,108,105,110,101,
116,46,105,116,62,10,10,0}; printf("%s",c); return 0;}

 ... questo non e' ANSI C ...
xche' non e' ANSI C?
non sto chiedendo aiuto per un compilatore ANSI? :-o
grazie

 grazie
HTH
C:\>iao Angelo
-- 
Posted via Mailgate.ORG Server - 
http://www.Mailgate.ORG

  grazie


  presente?
questa mi era sfuggita !!
;-))
