I have a code that is not running probably because a error in my makefile file. I have to run 3 functions from a external library but i cant use them because of thet undefined error
My implementation of the makefile archive
`CC = gcc
CFLAGS = -c -O2 -Wall
LDFLAGS =
all: zoom
zoom: lib_ppm.o zoom.o
$(CC) $(LDFLAGS) lib_ppm.o zoom.o -o zoom
lib_ppm.o: lib_ppm.c
$(CC) $(CFLAGS) -c lib_ppm.c
zoom.o: zoom.c
$(CC) $(CFLAGS) -c zoom.c
clean:
-rm -f *.o *~ zoom lena_copy.ppm test.ppm
lib_ppm.o: lib_ppm.h`
The call of the functions on the main:
#include <stdio.h>
#include <string.h>
#include "lib_ppm.h"
int main() {
/... logic .../
entry = read_ppm("lena.ppm", image_in);
if(entry < 0)
{
printf("read_ppm error");
return 0;
}
/... logic .../
entry = new_ppm(image_out, data.width*3, data.height*3);
if( entry < 0)
{
printf("new_ppm error");
return 0;
}
/... logic .../
entry = write_ppm("copy.ppm", image_out);
if( entry < 0)
{
printf("read_ppm error");
return 0;
}
}
the .h file
struct pixel_s {
unsigned char r, g, b;
};
struct image_s {
int width;
int height;
struct pixel_s *pix;
};
int read_ppm(char *file, struct image_s *image);
int write_ppm(char *file, struct image_s *image);
int new_ppm(struct image_s *image, int width, int height);
int free_ppm(struct image_s *image);
output:
/usr/bin/ld: /tmp/ccoHFVnw.o: in function `main':
/workspaces/softwarebasico/zoom.c:13: undefined reference to `read_ppm'
/usr/bin/ld: /workspaces/softwarebasico/zoom.c:20: undefined reference to `new_ppm'
/usr/bin/ld: /workspaces/softwarebasico/zoom.c:48: undefined reference to `write_ppm'
collect2: error: ld returned 1 exit status
Enzo R.C. is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.