Thread: Compiling two .o files and get error

  1. #1
    Registered User
    Join Date
    Oct 2001

    Question Compiling two .o files and get error

    I have two small .cpp files that I compile to an
    .o file like this:

    g++ -c scantest.cpp
    g++ -c scanini.cpp

    These file seem to compile ok.
    I then take them and compile them together
    like this:

    g++ -o scantest.o scanini.o -i686 -L/usr/local/lib/gcc-lib/i686-pc-linux-gnu/3.2.3 -lgcc -lc -lgcc -o scantest

    I now get the error
    /usr/lib/crt1.o: In function `_start':
    /usr/lib/crt1.o(.text+0x18): undefined reference to `main'
    collect2: ld returned 1 exit status

    Any ideas?
    thanks inadvance

  2. #2
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    The edge of the known universe
    Neither of your source files contain a main()
    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.

Popular pages Recent additions subscribe to a feed