I'm working on an assignment and now that I've finished I'm supossed to write a tester file to demonstrate how well the program works. While writing it I was just testing in a main file within the library itself. Now I'm getting an invalid pointer error when I try to link the testerfile (and I REALLY hope that's just because I'm linking the files incorrectly);


Anyway here's the structure that I have so far.

libraryfile.h
libraryfile.c
testerfile.c
testerfile.h


library file.h is setup with declarations for the library .c file as such:

extern int functionX(args);

How do I setup the testerfiles so that I can call all of the functions from library file.c?


I'm using the following comilation cmd in gcc:

gcc -g -ansi -pedantic -Wall -o xx.o libraryfile.c testerfile.c; ./xx.o

I also haven't written the testfile.h yet because I don't understand what I'd put in it (I think it can be empty, the professor just wants a .h for every .c file).

Thanks to anyone that can offer help, I'm pretty frustrated that I'm caught up on something I assume is simple after writing the entire library...

I figured out what I was doing wrong so I'll post the answer here in case anyone has the same problem.

Major facepalm: I forgot the -c tag.

Afiak the -c tag is required to link two c files together, and because I'm not used to linking files I completely spaced it. Good luck to anyone that has similar problems in the future!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.