Thread: Error: *&*$%$.o Multiply Defined

  1. #1

    Question Error: *&*$%$.o Multiply Defined

    I am using the GNU compiler and make utility for UNIX. I have added the "#ifndef wrapper" to my header file that is supposed to take care of this problem. What I have is three code files, each of which requires the same header file. I have #include'd this header into each code file. Can anyone think of any common silly errors that I am making that I can't seem to figure out.

  2. #2
    Has a Masters in B.S.
    Join Date
    Aug 2001
    do you define any variables, or functions in the header such as

    int x = 10;
    void function(void)
    // do something

    instead of

    int x;
    const int x;
    void function(void); // defined elsewhere
    inline void function(void)
    // do small something
    ADVISORY: This users posts are rated CP-MA, for Mature Audiences only.

  3. #3


    Here is my header, there is one int and one Macro actually initialized but they are not the ones the compiler is complaining about. It is complaining about Client() and Server().

    #ifndef HEADER_H_USED
    #define HEADER_H_USED

    #include <stdio.h>
    #include <ctype.h>
    #include <stdlib.h>
    #include <sys/types.h>
    #include <sys/socket.h>
    #include <netdb.h>
    #include <netinet/in.h>
    #include <arpa/inet.h>
    #include <strings.h>

    #define ReportError(msg) {perror(msg); exit(-1);}

    int random(), M= 2147483647;
    int srandom(unsigned);
    void IntroduceError(char*, double);
    char *GenerateData(int);
    int Server(), Client();
    double floor();
    char linebuffer[100];


    I have included this header in 3 files.

  4. #4
    Registered User
    Join Date
    Nov 2001

    Header file used in c file defining func

    I don't know if it matters or not, but the functions Client.c and Server.c have this same header file included.

  5. #5
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    The edge of the known universe
    > M= 2147483647
    You can't have these in a header file
    You should have
    &nbsp; extern int M;
    Then initialise it in one of your .c files

    > int Server(), Client();
    int Server();
    int Client();

    > double floor();
    This is in math.h - why is it here?

    > int random();
    > int srandom(unsigned);
    These are in stdlib.h (which you already include)

    > char linebuffer[100];
    Could be
    extern char linebuffer[100];
    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.

  6. #6
    Registered User
    Join Date
    Nov 2001

    Thumbs up Finished!!

    Thanks for your help! I got that header file from my professor...

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Linking problems in Visual Studio
    By h3ro in forum C++ Programming
    Replies: 5
    Last Post: 03-04-2008, 01:39 PM
  2. Dikumud
    By maxorator in forum C++ Programming
    Replies: 1
    Last Post: 10-01-2005, 06:39 AM
  3. Variables already defined while linking.
    By xconspirisist in forum C++ Programming
    Replies: 2
    Last Post: 06-10-2005, 05:20 AM
  4. DLL compiling question
    By Noose in forum Windows Programming
    Replies: 2
    Last Post: 12-16-2004, 06:16 AM
  5. Header files
    By borland_man in forum C++ Programming
    Replies: 14
    Last Post: 02-22-2002, 03:30 AM
Website Security Test