Results 1 to 11 of 11

Thread: linking qt3 to a library

  1. #1
    Join Date
    Nov 2006
    Posts
    14
    Thanks
    1

    Default linking qt3 to a library

    Hi everyone,
    I have a code written in C++ (code.cpp) which uses a library called minuit. I usually compile it with a command line:
    g++ -g -O2 -o code.out -I/home/Minuit-1_7_6/include -L/home/Minuit-1_7_6/lib -llcg_Minuit code.cpp
    Now I made a GUI to do the same thing , and I have rewritten code.ui.h to do what code.cpp used to do. But I am not able to change code.pro (which generates the Makefile using qmake) to link to the minuit library . Could anyone, please, help me to solve this problem? Thanks
    ---------------------------------------------------------code.pro---------------------------------------------
    TEMPLATE = app
    DEPENDPATH += header
    INCLUDEPATH += . header
    TMAKE_CXXFLAGS = -g
    INCLUDEPATH += /home/Minuit-1_7_6/include
    LIBS += -L/home/Minuit-1_7_6/lib -llcg_Minuit
    CONFIG = qt warn_off release
    # Input
    HEADERS += code.ui.h \
    version.h
    INTERFACES += code.ui
    SOURCES += main.cpp

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: linking qt3 to a library

    Quote Originally Posted by thebra View Post
    INCLUDEPATH += /home/Minuit-1_7_6/include
    LIBS += -L/home/Minuit-1_7_6/lib -llcg_Minuit
    It looks OK. Did you remember to rerun qmake to get a new Makefile?

  3. #3
    Join Date
    Nov 2006
    Posts
    14
    Thanks
    1

    Default Re: linking qt3 to a library

    yes I did using qmake -o Makefile code.pro and then make

  4. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: linking qt3 to a library

    Can you post the exact error message?

  5. #5
    Join Date
    Nov 2006
    Posts
    14
    Thanks
    1

    Default Re: linking qt3 to a library

    Thanks for your replies. After I type make I get the following (where the MODEL functions below are defined in minuit library)
    ----------------------------------------------------------------------------------------------------------------------------
    g++ -c -g -w -O2 -pipe -Wp,-D_FORTIFY_SOURCE=2 -fomit-frame-pointer -march=i586 -mtune=pentiumpro -DQT_NO_DEBUG -I/usr/lib/qt3/mkspecs/default -I. -I. -Iheader -I/home/Minuit-1_7_6/include -I/usr/lib/qt3//include -o code.o code.cpp
    In file included from code.cpp:28:
    code.ui.h: In member function `virtual void Code::test()':
    code.ui.h:1931: error: no matching function for call to `MODEL::MODEL(std::vector<double, std::allocator<double> >&, <unknown type>, std::vector<double, std::allocator<double> >&)'
    header/version.h:5: error: candidates are: MODEL::MODEL(const MODEL&)
    header/version.h:12: error: MODEL::MODEL(const std::vector<double, std::allocator<double> >&, const std::vector<double, std::allocator<double> >&, const std::vector<double, std::allocator<double> >&)
    {standard input}: Assembler messages:
    {standard input}:146100: Error: Local symbol `.LTHUNK0' can't be equated to undefined symbol `_ZN4BnmrD1Ev'
    {standard input}:146100: Error: Local symbol `.LTHUNK1' can't be equated to undefined symbol `_ZN4BnmrD0Ev'
    make: *** [bnmr.o] Error 1
    ------------------------------------------------------------------------------------------------------------------------------

  6. #6
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: linking qt3 to a library

    Quote Originally Posted by thebra View Post
    code.ui.h:1931: error: no matching function for call to `MODEL::MODEL( ... <unknown type> ...)'
    header/version.h:5: error: candidates are: MODEL::MODEL(const MODEL&)
    header/version.h:12: error: MODEL::MODEL(...)
    It looks like something on line 1931 in code.ui.h is causing troubles. What do you have there?

    Quote Originally Posted by thebra View Post
    {standard input}:146100: Error: Local symbol `.LTHUNK0' can't be equated to undefined symbol `_ZN4BnmrD1Ev'
    {standard input}:146100: Error: Local symbol `.LTHUNK1' can't be equated to undefined symbol `_ZN4BnmrD0Ev'
    Do you use Bnmr class somewhere? It looks like you have declared a Bnmr::~Bnmr() destructor, but you didn't implement it.

  7. #7
    Join Date
    Nov 2006
    Posts
    14
    Thanks
    1

    Default Re: linking qt3 to a library

    MODEL function is defined in the minuit library and called in version.h. Bnmr was defined in the header file as well. In fact the code compiles fine without linking to the minuit library ( as I remove the line 1931).

  8. #8
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: linking qt3 to a library

    Quote Originally Posted by thebra View Post
    MODEL function is defined in the minuit library and called in version.h.
    Judging from the compiler error, you just use it in a wrong way, or the header file is wrong --- note the "<unknown type>" in the error message. What parameter are you trying to pass to MODEL::MODEL()?

  9. #9
    Join Date
    Nov 2006
    Posts
    14
    Thanks
    1

    Default Re: linking qt3 to a library

    I am trying to pass data in form of ( x, y, dy) to be fitted using the minuit library. The code works perfect when compiled using a command line. But it doesn't when adjusted to fit in a GUI. Is it linking problem or just problems with unknown classes? I will check that again. But do you think there is nothing wrong with code.pro? Thanks

  10. #10
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: linking qt3 to a library

    Quote Originally Posted by thebra View Post
    Is it linking problem or just problems with unknown classes?
    That error message comes from the compiler, not linker, so either you have some typo in your code or missing #include directive.

    Quote Originally Posted by thebra View Post
    But do you think there is nothing wrong with code.pro?
    Yes, it looks OK.

  11. The following user says thank you to jacek for this useful post:

    thebra (11th November 2006)

  12. #11
    Join Date
    Nov 2006
    Posts
    14
    Thanks
    1

    Default Re: linking qt3 to a library

    I figured it out and it had to do with how classes of the C++ code were defined. Thanks for your help.

Similar Threads

  1. Wrap a static QT library inside an XPCOM component ?
    By Paul_Xul in forum Qt Programming
    Replies: 2
    Last Post: 3rd August 2010, 07:16
  2. static linking options
    By jcr in forum Installation and Deployment
    Replies: 4
    Last Post: 7th October 2006, 16:12
  3. import library linking
    By bruce1007 in forum Qt Programming
    Replies: 6
    Last Post: 19th May 2006, 10:27
  4. linking libraries
    By JustaStudent in forum Newbie
    Replies: 29
    Last Post: 2nd May 2006, 08:30
  5. I got two problems when I used static compiled library of QT4
    By qintm in forum Installation and Deployment
    Replies: 8
    Last Post: 20th April 2006, 08:52

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.