Results 1 to 5 of 5

Thread: Problem with link of external Library

  1. #1

    Default Problem with link of external Library

    Hello there,

    first, i have to tell, that i really tried to solve my problem by google and this forum, but I failed...

    What i found: http://kernelcoder.wordpress.com/201...library-in-qt/ and i tried to do that.

    I would like to use my external library libmathlib.a, which is located in Libs folder of project folder. Also i take a mathlib.h(which is h file of cpp file...these two files made libmathlib.a) so i take the mathlib.h and I placed it to Incs folder(like the tutorial says).

    In pro file of my project in qt are these extra lines:
    INCLUDEPATH += Incs
    LIBS += -L"Libs" -mathlib

    I was tried many of variants like:
    LIBS += /Libs/libmathlib.a
    LIBS += /Libs/libmathlib.a -mathlib
    and many of other which i found on google

    In cpp file in qt after that i have:
    #include "mathlib.h"
    and also this works:
    Mathlib m;(or Mathlib *m = new Mathlib())
    but when i was trying:
    m.add(1, 2);

    make says:
    undefined reference to `Mathlib::add(double, double)'

    Thanks for your help and really sorry for my english, I did my best

  2. #2
    Join Date
    Mar 2010
    Location
    Heredia, Costa Rica
    Posts
    257
    Thanks
    24
    Thanked 17 Times in 14 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Problem with link of external Library

    Try

    LIBS += -L/path/to/library -lLibrary_name_without_the_first_lib

    I am assuming that the library is libmathlib.so.

    Carlos.

  3. #3

    Default Re: Problem with link of external Library

    Hi,

    thanks for your help, but this still doesnt work:

    I tried it like:
    LIBS += -L/Libs -mathlib

    is this ok by your idea?

    Thank you very much for your help

  4. #4
    Join Date
    Mar 2010
    Location
    Heredia, Costa Rica
    Posts
    257
    Thanks
    24
    Thanked 17 Times in 14 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Problem with link of external Library

    hummm...

    Does the add function is :add(double, double) ? Because if it its parameters are integers or floats your compiler are sending 1 and 2 as double. So try to store 1 and 2 into integer or float variables A and B. And call add(A,B); to see if it works.

    Can you paste mathlib.h? I cannot find any copy on the web to check the add() function.

    Best.
    Last edited by qlands; 4th May 2011 at 08:17.

  5. #5
    Join Date
    Jan 2006
    Location
    Napoli, Italy
    Posts
    621
    Thanks
    5
    Thanked 86 Times in 81 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Problem with link of external Library

    The correct syntax is

    Qt Code:
    1. LIBS += -L/Libs -lmathlib
    To copy to clipboard, switch view to plain text mode 

    not the l (lowercase el) before the library name

    I think you need to improve your knowledge about building and linking executables
    Last edited by mcosta; 4th May 2011 at 08:21. Reason: updated contents
    A camel can go 14 days without drink,
    I can't!!!

Similar Threads

  1. how to link external library in qt linux?
    By qtlinuxnewbie in forum Qt Programming
    Replies: 2
    Last Post: 5th March 2010, 09:11
  2. Replies: 0
    Last Post: 1st November 2009, 20:28
  3. Problem with NCReport : can't link shared library !
    By QAmazigh in forum Qt Programming
    Replies: 4
    Last Post: 5th June 2009, 23:38
  4. Replies: 2
    Last Post: 14th January 2008, 18:09
  5. How to open external page link using tabwidget
    By jyoti in forum Qt Programming
    Replies: 2
    Last Post: 13th November 2006, 10:43

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.