Results 1 to 5 of 5

Thread: "Undefined reference to" error

  1. #1

    Default "Undefined reference to" error

    Good morning to everyone.
    First of all, I work in Linux Ubuntu 8.04 with Eclipse and Qt integration.
    I'm making a qt gui project named "rezclient". In my project I have to use some c functions of a library (librezShared.a) and other c functions declared in "rezCltProtocol.h" and defined in "rezCltProtocol.c". I have no problem with the library, but I have the error "undefined reference to" the functions of the rezCltProtocol.h file.

    - This is the message of console:

    "make debug
    make -f Makefile.Debug
    make[1]: Entering directory `/home/francesco/Scrivania/SERVER/eclipseWorkspace/rezclient'
    g++ -Wl,-rpath,/usr/local/Trolltech/Qt-4.4.3/lib -o rezclient debug/main.o debug/rezclient.o debug/moc_rezclient.o -L/usr/local/Trolltech/Qt-4.4.3/lib -lrezShared -L/home/francesco/Scrivania/SERVER/sharedSrc/Debug -lQtGui -L/usr/local/Trolltech/Qt-4.4.3/lib -L/usr/X11R6/lib -lXext -lX11 -lQtCore -lz -lm -lrt -ldl -lpthread
    debug/rezclient.o: In function `rezclient:n_pushButton_clicked()':
    make[1]: Leaving directory `/home/francesco/Scrivania/SERVER/eclipseWorkspace/rezclient'
    /home/francesco/Scrivania/SERVER/eclipseWorkspace/rezclient/rezclient.cpp:34: undefined reference to `execCmdHeartbeat(int, unsigned int, double*)'
    /home/francesco/Scrivania/SERVER/eclipseWorkspace/rezclient/rezclient.cpp:35: undefined reference to `execCmdGetClients(int, unsigned int, tRezClientList*)'
    collect2: ld returned 1 exit status
    make[1]: *** [rezclient] Error 1
    make: *** [debug] Error 2"

    - This is my .pro file:

    TEMPLATE = app
    TARGET = rezclient
    QT += core \
    gui

    # Input
    HEADERS += rezclient.h
    SOURCES += main.cpp \
    rezclient.cpp
    FORMS += rezclient.ui
    INCLUDEPATH += /home/francesco/Scrivania/SERVER/sharedSrc; \
    /home/francesco/Scrivania/SERVER/rezClient/src;
    LIBS += -lrezShared \
    -L/home/francesco/Scrivania/SERVER/sharedSrc/Debug

    And in my code I use this instructions to include the headers files:

    extern "C"{
    #include "../../sharedSrc/commondefs.h"
    #include "../../sharedSrc/rezProtocol.h"
    #include "../../sharedSrc/tcpsocket.h"
    #include "../../rezClient/src/rezCltProtocol.h"
    }

    I really don't know how to solve this problem. I hope you'll help me.
    Good morning.
    Francesco.

    Ps. Excuse me for my english.
    Last edited by f.tristano; 2nd February 2009 at 08:54.

  2. #2
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: "Undefined reference to" error

    Where are execCmdHeartbeat() and execCmdGetClients() implemented?
    J-P Nurmi

  3. #3
    Join Date
    Dec 2006
    Posts
    849
    Thanks
    6
    Thanked 163 Times in 151 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: "Undefined reference to" error

    two possible errors:

    * either those two functions are C (not C++!) functions: then the header was included in some C++ file without the extern "C"
    (You can see that those function-calls where compiled as C++ function calls because they have signature. C-calls are just a function name (no argument types).)

    * those really are C++ functions and you just do not link the lib or object file that contains them

    HTH

  4. #4

    Default Re: "Undefined reference to" error

    Reply to jpn:
    The two functions are implemented in my rezclient.cpp file (I attached the file).

    Reply to caduel:
    the two functions are C functions and I included them with extern C
    Attached Files Attached Files

  5. #5

    Default Re: "Undefined reference to" error

    I solved.
    I just added in my .pro file the source file rezCltProtocol.c.
    However, thanks.

Similar Threads

  1. nmake error during .pro compiling
    By mattia in forum Installation and Deployment
    Replies: 5
    Last Post: 18th June 2008, 11:15
  2. how to add static library into qmake
    By Namrata in forum Qt Tools
    Replies: 1
    Last Post: 20th November 2007, 18:33
  3. Error compiling psql plugin
    By vieraci in forum Installation and Deployment
    Replies: 4
    Last Post: 7th October 2007, 03:49
  4. error undefined reference ...............
    By amit_pansuria in forum Qt Programming
    Replies: 2
    Last Post: 8th June 2007, 15:28
  5. how to correctly compile threads support?
    By srhlefty in forum Installation and Deployment
    Replies: 9
    Last Post: 25th June 2006, 20:15

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.