Compiling two .o files and get error

This is a discussion on Compiling two .o files and get error within the C++ Programming forums, part of the General Programming Boards category; I have two small .cpp files that I compile to an .o file like this: g++ -c scantest.cpp g++ -c ...

  1. #1
    Registered User
    Join Date
    Oct 2001
    Posts
    18

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

Popular pages Recent additions subscribe to a feed

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