Visualizzazione dei risultati da 1 a 3 su 3
  1. #1
    Utente di HTML.it L'avatar di cerza
    Registrato dal
    Oct 2009
    Messaggi
    310

    error LNK2001 in cpp

    Salve,
    sono alle prese con del codice cpp ed opengl, ho il file .ccp dove ho implementato la funzione read_texture ed il file .h dove ho dichiarato tale funzione; mi succedono cose strane del tipo se cerco tutti i riferimenti della funzione definita nel .h ne trovo 2, se invece cerco tutti i riferimenti della funzione implementata nel file .cpp ne trovo uno solo!!!!! alquanto strano visto che si dovrebbe trattare della stessa funzione
    altra cosa è l'errore seguente:
    error LNK2001: simbolo esterno "unsigned int * __cdecl read_texture(char const *,int *,int *,int *)" (?read_texture@@YAPAIPBDPAH11@Z) non risolto, che a sua volta provoca l'errore LNK1102
    guardando un pò in rete ho capito che non riesce a fare il collegamento con tale funzione ma non riesco a capire dove devo intervenire.
    mi potreste aiutate cortesemente??
    grazie in anticipo

    maria

  2. #2
    Se postassi il pezzo di codice interessato sarebbe meglio
    lolide
    Java Programmer

    Informati

  3. #3
    Utente di HTML.it L'avatar di cerza
    Registrato dal
    Oct 2009
    Messaggi
    310
    grazie per aver risposto, il codice è il seguente:
    codice:
    unsigned *read_texture(char *name, int *width, int *height, int *components) {
        unsigned *base, *lptr;
        unsigned char *rbuf, *gbuf, *bbuf, *abuf;
        ImageRec *image;
        int y;
    
        image = ImageOpen(name);
        
        if(!image)
    	return NULL;
        (*width)=image->xsize;
        (*height)=image->ysize;
        (*components)=image->zsize;
        base = (unsigned *)malloc(image->xsize*image->ysize*sizeof(unsigned));
        rbuf = (unsigned char *)malloc(image->xsize*sizeof(unsigned char));
        gbuf = (unsigned char *)malloc(image->xsize*sizeof(unsigned char));
        bbuf = (unsigned char *)malloc(image->xsize*sizeof(unsigned char));
        abuf = (unsigned char *)malloc(image->xsize*sizeof(unsigned char));
        if(!base || !rbuf || !gbuf || !bbuf)
          return NULL;
        lptr = base;
        for(y=0; y<image->ysize; y++) {
    	if(image->zsize>=4) {
    	    ImageGetRow(image,rbuf,y,0);
    	    ImageGetRow(image,gbuf,y,1);
    	    ImageGetRow(image,bbuf,y,2);
    	    ImageGetRow(image,abuf,y,3);
    	    rgbatorgba(rbuf,gbuf,bbuf,abuf,(unsigned char *)lptr,image->xsize);
    	    lptr += image->xsize;
    	} else if(image->zsize==3) {
    	    ImageGetRow(image,rbuf,y,0);
    	    ImageGetRow(image,gbuf,y,1);
    	    ImageGetRow(image,bbuf,y,2);
    	    rgbtorgba(rbuf,gbuf,bbuf,(unsigned char *)lptr,image->xsize);
    	    lptr += image->xsize;
    	} else if(image->zsize==2) {
    	    ImageGetRow(image,rbuf,y,0);
    	    ImageGetRow(image,abuf,y,1);
    	    latorgba(rbuf,abuf,(unsigned char *)lptr,image->xsize);
    	    lptr += image->xsize;
    	} else {
    	    ImageGetRow(image,rbuf,y,0);
    	    bwtorgba(rbuf,(unsigned char *)lptr,image->xsize);
    	    lptr += image->xsize;
    	}
        }
        ImageClose(image);
        free(rbuf);
        free(gbuf);
        free(bbuf);
        free(abuf);
    
        return (unsigned *) base;
    }
    tale funzione viene richiamata in questo modo:
    codice:
    init_Mare(argc == 1 ? "../texture/water.bw" : argv[1]);
    buona gironata

    maria

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2024 vBulletin Solutions, Inc. All rights reserved.