Thread: Help With Error Msg?

  1. #1
    Registered User
    Join Date
    Jan 2002
    Posts
    10

    Help With Error Msg?

    Hi!!
    When I compile my code for a program that (agian!!) ouputs a calender, I get this error msg:

    > g++ -o ./Calender ./Calender.o -s
    ! C:\Program Files\GNUCPP\bin\..\lib\gcc-lib\i386-mingw32\2.95.2\..\..\..\..
    * \i386-mingw32\lib\libmingw32.a(main.o)(.text+0x8e): undefined reference to `
    * inMain@16'
    ! make: *** [Calender] Error 1
    ---- Make had errors. Right click error line to open file.

    I have attached my code. Does anyone know what this means?!
    HELP!!!

    Claire

  2. #2
    Registered User
    Join Date
    Jan 2002
    Posts
    363
    You forgot to add a main to the program.
    You can compile it to object code with out a main (.o extension) but you can't create an executable.

  3. #3
    Registered User
    Join Date
    Jan 2002
    Posts
    10
    sorry?!
    Can u explain that in simple english, coz I'm only a beginner!!

    If you mean an int/main piece of code, I do have one of those, and I include my calender.cpp at the start of it.

    But, I simply can't compile this code I have here!!

    Thanks!

  4. #4
    Registered User
    Join Date
    Jan 2002
    Posts
    363
    I don't see a file called calander.cpp included
    I only see a calender.h
    Last edited by shtarker; 02-01-2002 at 06:52 AM.

  5. #5
    It's full of stars adrianxw's Avatar
    Join Date
    Aug 2001
    Posts
    4,829
    >>> include my calender.cpp at the start of it.

    If you mean you are using #include, with a .cpp file, then don't. For a projrct the size of yours, put all of the code in a single .cpp file.
    Wave upon wave of demented avengers march cheerfully out of obscurity unto the dream.

  6. #6
    Unregistered
    Guest
    You need to add main() to your code some where
    --------------------------------------------
    int main()
    {

    //some code

    return 0;
    }

  7. #7
    Registered User
    Join Date
    Jan 2002
    Posts
    363
    ohhhh i think i see your problem now.
    Of course you can't compile that piece of code.
    When you include it in another file then the compiler should automaticly compile it.
    However its best just to compile them seperatly and link them together at the end. It still should work and is the simpelist way of doing it.
    For mingw this is done by either:

    g++ -o FINAL_EXE_NAME Main.cpp calender.cpp

    or:

    g++ -c Main.cpp
    g++ -c calender.cpp
    g++ --c FINAL_EXE_NAME Main.o calender.o

    I can't be bothered to explain the difference between them.
    So just tell me if you really want to find out.

Popular pages Recent additions subscribe to a feed