I have a small project that I need to compile. I have one header and one source that I have created and a nearly empty driver.c that includes my header.
Observe:
// iol.h
#ifndef __IOL_HEADER
#define __IOL_HEADER
/* program: iol.h
date: 5 October 2010
*/
#define UNIX 1
#define WINDOWS 2
#define OS UNIX
#if OS == UNIX
#include <ncurses.h>
#elif OS == WINDOWS
#include <conio.h>
#include <windows.h>
// Function declarations!
#endif
void iol_init(void);
#endif
Now my implementation file:
// iol.c
#include <string.h>
#include <stdlib.h>
#include "iol.h"
void iol_init(void) {
#if OS == WINDOWS
/* no startup required for windows */
#elif OS == UNIX
initscr();
noecho();
cbreak();
keypad(stdscr, 1);
// Implmntn continues....
Now the driver that includes my header and provides the main ():
//main.c
#include "iol.h"
My bash command:
gcc iol.c driver.c -l"ncurses"
I get back:
/tmp/ccmmW6hQ.o:iol.c:(.text+0x83f): first defined here
/tmp/ccwIKUaT.o: In function 'isEscaping':
driver.c:(.text+0xbab): multiple definition of 'isEscaping'
/tmp/ccmmW6hQ.o:iol.c:(.text+0xbab): first defined here
/tmp/ccwIKUaT.o: In function 'initSeq':
..
driver.c:(.text+0x149): undefined reference to 'iol_prnstr'
driver.c:(.text+0x178): undefined reference to 'iol_putch'
..
driver.c:(.text+0x726): undefined reference to 'iol_display'
collect2: ld returned 1 exit status
I just want to get to point where I can compile this, and start ripping my hair out 'cuz of all my seg-faults. What's the problem in my setup? I RTFM on the Gnu C Compiler apparently I'm doing what I'm supposed to, which is declare stuff in iol.h, define in iol.c, and use it in driver.c this is pretty trivial stuff maybe I just need a second set of eyes :S
I'm actually getting a long list of errors, if anyone thinks that's relevant, I'm happy to post the whole source.