makefile problem

This is a discussion on makefile problem within the C Programming forums, part of the General Programming Boards category; Hello! Im quite new to C programming, especially with makefiles. I've read many posts but still i cant compile my ...

  1. #1
    Registered User
    Join Date
    May 2005
    Posts
    8

    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
    }

  2. #2
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,851
    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.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

  3. #3
    Registered User
    Join Date
    May 2005
    Posts
    8
    thanks! i got it working

  4. #4
    ---
    Join Date
    May 2004
    Posts
    1,379
    and *arrayofpixels doesnt point to anything.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. WS_POPUP, continuation of old problem
    By blurrymadness in forum Windows Programming
    Replies: 1
    Last Post: 04-20-2007, 07:54 PM
  2. problem with Makefile separator
    By luca in forum Tech Board
    Replies: 6
    Last Post: 01-15-2007, 10:20 AM
  3. Problem with makefile, how to use the -lm oh this?
    By Nazgulled in forum C Programming
    Replies: 1
    Last Post: 04-07-2006, 02:29 PM
  4. Laptop Problem
    By Boomba in forum Tech Board
    Replies: 1
    Last Post: 03-07-2006, 06:24 PM
  5. Replies: 5
    Last Post: 11-07-2005, 11:34 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21