Results 1 to 3 of 3

Thread: 'undefined reference to .... :: .... ' Problem with Ubuntu and QT

  1. #1
    Join Date
    Jun 2010
    Posts
    1
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default 'undefined reference to .... :: .... ' Problem with Ubuntu and QT

    Hello,
    I've been looking for a solution to my problem for a while, but none of the given solutions worked, so I decided to ask myself.

    The only fault I get is ":-1: error: collect2: ld returned 1 exit status".
    But "/TestApplication/sample/mainwindow.cpp:52: undefined reference to `HoGDetector::HoGDetector(int)'" makes me assume that it is an inclusion-Problem.

    (i reduced the code, so I would still get the same problem, but i left all the includes)

    mainwindow.cpp:
    Qt Code:
    1. #include "mainwindow.h"
    2. #include "ui_mainwindow.h"
    3. #include <opencv/cv.h>
    4. #include <opencv/highgui.h>
    5. #include <string>
    6. #include <iostream>
    7. #include <fstream>
    8. #include <detection.h>
    9. #include <detector.h>
    10. #include <HoGDetector.h>
    11. #include <VJDetector.h>
    12. #include "im/data.h"
    13. #include "im/io.h"
    14. //#include <postprocess.h>
    15. #include <stdio.h>
    16.  
    17. using namespace std;
    18.  
    19. #ifdef TIME
    20. extern "C"{
    21. #include "rs/time.h"
    22. }
    23. #endif
    24.  
    25. HoGDetector* detector;
    26.  
    27. MainWindow::MainWindow(QWidget *parent) :
    28. QMainWindow(parent),
    29. ui(new Ui::MainWindow)
    30. {
    31. ui->setupUi(this);
    32.  
    33.  
    34. }
    35.  
    36. MainWindow::~MainWindow()
    37. {
    38. delete ui;
    39. }
    40.  
    41. void MainWindow::changeEvent(QEvent *e)
    42. {
    43. QMainWindow::changeEvent(e);
    44. switch (e->type()) {
    45. case QEvent::LanguageChange:
    46. ui->retranslateUi(this);
    47. break;
    48. default:
    49. break;
    50. }
    51. int verbosity = 1;
    52. HoGDetector* detector = new HoGDetector(verbosity);
    53. }
    To copy to clipboard, switch view to plain text mode 

    mainwindow.h
    Qt Code:
    1. #ifndef MAINWINDOW_H
    2. #define MAINWINDOW_H
    3.  
    4. #include <QMainWindow>
    5. #include <opencv/cv.h>
    6. #include <opencv/highgui.h>
    7. #include <string>
    8. #include <detection.h>
    9. #include <detector.h>
    10. #include <HoGDetector.h>
    11. #include <VJDetector.h>
    12. #include <postprocess.h>
    13.  
    14. namespace Ui {
    15. class MainWindow;
    16. }
    17.  
    18. class MainWindow : public QMainWindow {
    19. Q_OBJECT
    20. public:
    21. MainWindow(QWidget *parent = 0);
    22. ~MainWindow();
    23.  
    24. protected:
    25. void changeEvent(QEvent *e);
    26.  
    27. private:
    28. Ui::MainWindow *ui;
    29. };
    30.  
    31. #endif // MAINWINDOW_H
    To copy to clipboard, switch view to plain text mode 

    sample.pro
    Qt Code:
    1. TARGET = TestApplication
    2. TEMPLATE = app
    3. SOURCES += main.cpp \
    4. mainwindow.cpp
    5. HEADERS += mainwindow.h
    6. FORMS += mainwindow.ui
    7. INCLUDEPATH += /vol/opencv/include \
    8. /vol/is/include \
    9. /vol/is/contrib/include \
    10. /vol/esmeralda/include \
    11. /vol/is/contrib/include/ml \
    12. /vol/is/contrib/include/iul
    13. LIBS += -L/vol/opencv/lib \
    14. -L/vol/is/lib \
    15. -L/vol/is/contrib/lib \
    16. -L/vol/esmeralda/lib \
    17. -L/vol/is/contrib/lib/ml/lib \
    18. -L/vol/is/contrib/lib/iul \
    19. -lcxcore \
    20. -lcv \
    21. -lhighgui \
    22. -lcvaux \
    23. -lim \
    24. -lmx \
    25. -lrs \
    26. -lz \
    27. -lm \
    28. -ldl \
    29. -lpthread \
    30. -lImageUtilityLibrary \
    31. -lMathLibrary \
    32. -lfloatfann \
    33. -lhistogram \
    34. -lmeanshift
    To copy to clipboard, switch view to plain text mode 

    i also used the bashrc-file using:

    " source ~/.bashrc "
    and checked with echo $LD_LIBRARY_PATH that all the necessary paths were included
    "/vol/opencv/lib:/vol/qt/lib:/export/usr/share/jre/1.5/lib/i386/:/vol/esmeralda/lib:/vol/is/contrib/lib:/vol/is/lib:/export/usr/lib:/vol/robot/share/MetraLabs/tmp/opt/MetraLabs/lib:"

    The file HoGDetect.h is in the folder: "/vol/is/contrib"

    As I am new to Qt, C++ and Linux this is giving me headaches.
    I really hope I did not forget anything important.

    Thank you for your advices in advance

  2. #2
    Join Date
    Sep 2009
    Location
    UK
    Posts
    2,447
    Thanks
    6
    Thanked 348 Times in 333 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: 'undefined reference to .... :: .... ' Problem with Ubuntu and QT

    No HoGDetect.cpp or is everything in HoGDetect.h?

  3. #3
    Join Date
    Apr 2010
    Posts
    769
    Thanks
    1
    Thanked 94 Times in 86 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11

    Default Re: 'undefined reference to .... :: .... ' Problem with Ubuntu and QT

    It isn't an include problem - the error indicates that the problem is occuring during linkage, not compilation. So whatever library contains your HoGDetector class is either not being found, or it doesn't contain a constructor that takes an int as an argument.

Similar Threads

  1. undefined reference
    By digidas in forum Newbie
    Replies: 9
    Last Post: 19th May 2010, 13:04
  2. Undefined reference to crt
    By derektaprell in forum Installation and Deployment
    Replies: 0
    Last Post: 20th October 2009, 08:34
  3. Undefined Reference To...
    By ManuMies in forum Qt Programming
    Replies: 6
    Last Post: 10th February 2009, 12:14
  4. Undefined reference
    By Salazaar in forum Newbie
    Replies: 12
    Last Post: 23rd May 2007, 10:21
  5. Problem: Undefined reference
    By stiank81 in forum Qt Programming
    Replies: 4
    Last Post: 16th February 2006, 14:17

Tags for this Thread

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.