Thread: Linker error when compiling Qt program

  1. #1
    Registered User
    Join Date
    Apr 2008
    Posts
    1

    Unhappy Linker error when compiling Qt program

    Hi,

    I am getting linker errors when i compile 3 modules as given below

    The module layout is as below

    Code:
    Z.h
    {
    int s;
    void B();
    }
    
    Z.c
    {
    int s = 1;
    void B() {
    statements;
    }
    }
    
    Y.c{
    A() {
    if (s)
    B(); }
    
    X.cpp{
    extern int s;
    s=0;
    A();
    }
    Rules for compilation :

    Z : Y Z.h
    cc -o Z Y

    Y.o : Z.h Y.c
    cc -c -o Y.o Y.c

    Z : Z.h Z.c
    cc -c -o Z.c

    Y : Y.o Z
    cc -o Y Y.o Z

    I get a linker error when i compile the modules as follows
    /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/../../../crt1.o(.text+0x1: In functi
    n `_start':
    ../sysdeps/i386/elf/start.S:77: undefined reference to `main'
    Y.o(.text+0x1e3): In function `makedist':
    : undefined reference to `rint'
    Y.o(.text+0x2e6): In function `inverttable':
    : undefined reference to `rint'
    Y.o(.text+0x312): In function `inverttable':
    : undefined reference to `rint'
    collect2: ld returned 1 exit status
    make: *** [Y] Error 1


    Please help....

    Regards,
    Shashidhara

  2. #2
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    None of your modules have a "main".

    Since you have stripped down your code, I can't really say what's wrong with "rint"

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

  3. #3
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,659
    Perhaps rint is in math

    Say
    gcc -o prog file.o -lm
    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

Similar Threads

  1. Screwy Linker Error - VC2005
    By Tonto in forum C++ Programming
    Replies: 5
    Last Post: 06-19-2007, 02:39 PM
  2. adding an #include stops my program from compiling
    By angelscars in forum C++ Programming
    Replies: 5
    Last Post: 11-11-2005, 05:24 PM
  3. Dikumud
    By maxorator in forum C++ Programming
    Replies: 1
    Last Post: 10-01-2005, 06:39 AM
  4. Replies: 3
    Last Post: 04-19-2004, 08:09 AM