• Miércoles 15 de Mayo de 2024, 15:21

Autor Tema:  Problema practica C  (Leído 701 veces)

pancherre

  • Nuevo Miembro
  • *
  • Mensajes: 2
    • Ver Perfil
Problema practica C
« en: Domingo 19 de Abril de 2009, 14:45 »
0
Hola buenas chicos es la primera vez que escribo aqui, asi que no se que tal se me dará jejeje. El caso es que tengo una practica que hacer que versa sobre la orden Grep de UNIX, y ya la tengo implementada y todo, he creado el makefile y eso, pero el problema es que me da es que cuando compilo el makefile me da "undefined reference to..." y ahi el nombre de una funcion. Estoy desesperado, no se que puede ser, os incluyo aqui el codigo a ver si me podeis echar una mano ok? Muchas gracias por adelantado!
Os pongo el makefile y el .h que uso  por si es esto lo que falla

Makefile
Código: Text
  1.  
  2. # Directorios de la aplicación
  3. INCLUDEDIR = ../include
  4. LIBDIR = ../lib
  5. BINDIR = ../bin
  6.  
  7. # Programas estandar que se utilizan
  8. # Archivador
  9. AR = ar
  10. AFLAGS = rs
  11. # Compilador
  12. CC = gcc
  13. CFLAGS = -I$(INCLUDEDIR) -L$(LIBDIR)
  14.  
  15. # Biblioteca de usuario y ficheros que forman parte de la biblioteca
  16.  
  17. BIBLIOTECA = $(LIBDIR)/libgrep_rw.a
  18. BIBLIOTECAB= $(LIBDIR)/libgrep_mmap.a
  19.  
  20. #Programa ejecutable y ficheros que forman parte del mismo
  21.  
  22. OBJETOS_PROGRAMA = grep.o
  23.  
  24. #Objetivo "all" que programa los ejecutables y ficheros que forman partes del mismo
  25. all: $(BINDIR)/grep_mmap $(BINDIR)/grep_rw
  26. $(BINDIR)/grep_mmap: $(OBJETOS_PROGRAMA) $(BIBLIOTECAB)
  27.     $(CC) $(OBJETOS_PROGRAMA) $(CFLAGS) -lgrep_mmap -Wall -o $(BINDIR)/grep_mmap            
  28. $(BINDIR)/grep_rw: $(OBJETOS_PROGRAMA) $(BIBLIOTECA)
  29.     $(CC) $(OBJETOS_PROGRAMA) $(CFLAGS) -lgrep_rw -Wall -o $(BINDIR)/grep_rw
  30.  
  31. #Biblioteca que se crea
  32. $(BIBLIOTECA): grep_rw.o    
  33.     $(AR) $(AFLAGS) $(BIBLIOTECA) grep_rw.o
  34. $(BIBLIOTECAB): grep_mmap.o
  35.     $(AR) $(AFLAGS) $(BIBLIOTECAB) grep_mmap.o
  36. $(OBJETOS_PROGRAMA) $(OBJETOS_BIBLIOTECA): $(INCLUDEDIR)/grep.h
  37.  
  38. #Objetivo "prueba" con la prueba de los dos ejecutables
  39. prueba: $(BINDIR)/grep_mmap $(BINDIR)/grep_rw
  40.     ../bin/grep_rw include ~/Grep/src/grep_rw.c
  41.     ../bin/grep_mmap include ~/Grep/src/grep_mmap.c
  42.  
  43.  
  44.  

GREP.H

Código: Text
  1.  
  2. #if !defined (_GREP_H_)
  3. #define _GREP_H_
  4.  
  5. # include <stdio.h>
  6. # include <stdlib.h>
  7. # include <fcntl.h>
  8. # include <string.h>
  9. # include <sys/stat.h>
  10. # include <sys/types.h>
  11. # include <sys/time.h>
  12. # include <time.h>
  13. # include <sched.h>
  14. # include <dirent.h>
  15. # include <unistd.h>
  16. # include <sys/mman.h>
  17. # include <unistd.h>
  18. # include <fcntl.h>
  19.  
  20.    void proyectar (int ds,int argc, char *argv[],int i);
  21.    void grep_rw(char *argv[],int ds,int i);
  22.    int buscarpatron(char *texto,char *cadena,char *argv[],int w);
  23.    
  24. #endif
  25.  
  26.  
Estos son los programas, a las funciones que estan en grep.h se las hace referencia desde otros modulos, y creo que es ahí donde está el error.
« última modificación: Domingo 19 de Abril de 2009, 16:16 por pancherre »

pancherre

  • Nuevo Miembro
  • *
  • Mensajes: 2
    • Ver Perfil
Re: Problema practica C
« Respuesta #1 en: Domingo 19 de Abril de 2009, 14:57 »
0
Si necesitais algo mas avisadme, intentad ayudarme por favor!

m0skit0

  • Miembro de PLATA
  • *****
  • Mensajes: 2337
  • Nacionalidad: ma
    • Ver Perfil
    • http://fr33kk0mpu73r.blogspot.com/
Re: Problema practica C
« Respuesta #2 en: Lunes 20 de Abril de 2009, 11:48 »
0
Vale, ¿pero qué función no está referenciada? Podrías empezar por eso.