Linux Format forums Forum Index Linux Format forums
Help, discussion, magazine feedback and more
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Using extra libraries with a QT based program

 
Post new topic   Reply to topic    Linux Format forums Forum Index -> Programming
View previous topic :: View next topic  
Author Message
nerdmaster



Joined: Thu Jul 14, 2005 11:18 am
Posts: 52

PostPosted: Wed Dec 07, 2005 3:40 pm    Post subject: Using extra libraries with a QT based program Reply with quote

I was wondering if anyone can advise me about using extra libraries with a qmake based program, since I'm quite new to these aspects of programming (with most of my experience over the past 2 years being based on Java)

I'm writing a C++ based program for a computer vision project. As a result, there are a number of external (static) libraries I need, these are for the image processing and display functions. I am also planning on making the application graphical and have opted to use the QT toolkit, using qmake.

I was wondering, how do I go about importing these libraries? (bearing in mind that I don't have much experience with make)
Back to top
View user's profile Send private message
Nigel
LXF regular


Joined: Fri Apr 08, 2005 9:03 pm
Posts: 1141
Location: Gloucestershire, UK

PostPosted: Wed Dec 07, 2005 4:37 pm    Post subject: RE: Using extra libraries with a QT based program Reply with quote

You need to add them to the link statement in your makefile.
To link in a library called libfred.a that exists in directory /home/joe/libs (not part of $LD_LIBRARY_PATH) you would add the following two parameters to your link statement
-L /home/joe/libs -lfred

(-L adds a directory to those that will be searched for libraries, -l links in a library. The "lib" prefix and ".a" (or ".so") suffix is added by the compiler/linker.

To call routines in the library you will have to include the appropriate header file in your C++ source.
_________________
Hope this helps,

Nigel.
Back to top
View user's profile Send private message
ChrisCook



Joined: Tue Jan 17, 2006 3:26 am
Posts: 1

PostPosted: Tue Jan 17, 2006 3:54 am    Post subject: RE: Using extra libraries with a QT based program Reply with quote

I do something like this in a project Im working on currently (http://quarkplusplus.sf.net)

In my qmake project file (*.pro) i have
Code:
INCLUDEPATH += . src /usr/include/python2.4
LIBS += -lpython2.4

this lets me do somthing like
Code:
#include <Python.h>

which includes the file Python.h from /usr/include/python2.4/

the final executable file will be linked with the python2.4 library which it finds from the standard library path. if the library is somewhere else like in your home directory, use
Code:
LIBS += -L/home/joe/libs -lfred
as in Nigel's example.
Back to top
View user's profile Send private message
View previous topic :: View next topic  
Display posts from previous:   
Post new topic   Reply to topic    Linux Format forums Forum Index -> Programming All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
Linux Format forums topic RSS feed 


Powered by phpBB © 2001, 2005 phpBB Group


Copyright 2011 Future Publishing, all rights reserved.


Web hosting by UKFast