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

This is a discussion on Error: *&*$%$.o Multiply Defined within the C Programming forums, part of the General Programming Boards category; I am using the GNU compiler and make utility for UNIX. I have added the "#ifndef wrapper" to my header ...

  1. #1
    Unregistered
    Guest

    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
    Posts
    2,267
    do you define any variables, or functions in the header such as

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

    instead of

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

  3. #3
    Unregistered
    Guest

    Definitions

    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];

    #endif

    I have included this header in 3 files.

  4. #4
    Registered User
    Join Date
    Nov 2001
    Posts
    5

    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 wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,588
    > 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();
    Try
    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.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

  6. #6
    Registered User
    Join Date
    Nov 2001
    Posts
    5

    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

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