-
makefile problem
Hello!
Im quite new to C programming, especially with makefiles. I've read many posts but still i cant compile my program. I'm running Gentoo Linux with newest GCC. I have three files: fb.h, fb.c and main.c. Make properly makes main.o and fb.o but while linking says that that arrayofpixels is already defined in main.o and there is multiple definition in fb.o
main.c:
Code:
#include "fb.h"
void main()
{
fbInit();
arrayofpixels[x+y*w]=somecolour;
fbDeinit();
}
fb.h:
Code:
#ifndef __MYFB_H_
#define __MYFB_H_
#include <linux/fb.h> // this is system wide framebuffer-device definition file
char *arrayofpixels;
void fbInit();
void fbDeinit();
#endif
fb.c:
Code:
#include <linux/fb.h> // this is system wide framebuffer-device definition file
#include "fb.h"
void fbInit()
{
// init stuff and allocate memory for array of pixels
}
void fbDeinit()
{
// undo everything
}
-
In the .h file, you should have
extern char *arrayofpixels;
In ONE .c file, you should have
char *arrayofpixels;
Finally, main returns an int, not void.
-
-
and *arrayofpixels doesnt point to anything.