954,492 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

linking header files and tester files

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...

NerdyChick27
Newbie Poster
8 posts since Sep 2011
Reputation Points: 10
Solved Threads: 0
 

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!

NerdyChick27
Newbie Poster
8 posts since Sep 2011
Reputation Points: 10
Solved Threads: 0
 

This question has already been solved

Post: Markdown Syntax: Formatting Help
You
View similar articles that have also been tagged: