KDE-Apps.org Applications for the KDE-Desktop 
 GTK-Apps.org Applications using the GTK Toolkit 
 GnomeFiles.org Applications for GNOME 
 MeeGo-Central.org Applications for MeeGo 
 CLI-Apps.org Command Line Applications 
 Qt-Apps.org Free Qt Applications 
 Qt-Prop.org Proprietary Qt Applications 
 Maemo-Apps.org Applications for the Maemo Plattform 
 Java-Apps.org Free Java Applications 
 eyeOS-Apps.org Free eyeOS Applications 
 Wine-Apps.org Wine Applications 
 Server-Apps.org Server Applications 
 apps.ownCloud.com ownCloud Applications 
 KDE-Look.org Artwork for the KDE-Desktop 
 GNOME-Look.org Artwork for the GNOME-Desktop 
 Xfce-Look.org Artwork for the Xfce-Desktop 
 Box-Look.org Artwork for your Windowmanager 
 E17-Stuff.org Artwork for Enlightenment 
 Beryl-Themes.org Artwork for the Beryl Windowmanager 
 Compiz-Themes.org Artwork for the Compiz Windowmanager 
 EDE-Look.org Themes for your EDE Desktop 
 Debian-Art.org Stuff for Debian 
 Gentoo-Art.org Artwork for Gentoo Linux 
 SUSE-Art.org Artwork for openSUSE 
 Ubuntu-Art.org Artwork for Ubuntu 
 Kubuntu-Art.org Artwork for Kubuntu 
 LinuxMint-Art.org Artwork for Linux Mint 
 Frugalware-Art.org Artwork for Frugalware Linux 
 Arch-Stuff.org Artwork and Stuff for Arch Linux 
 Fedora-Art.org Artwork for Fedora Linux 
 Mandriva-Art.org Artwork for Mandriva Linux 
 KDE-Files.org Files for KDE Applications 
 OpenTemplate.org Documents for OpenOffice.org
 GIMPStuff.org Files for GIMP
 InkscapeStuff.org Files for Inkscape
 ScribusStuff.org Files for Scribus
 BlenderStuff.org Textures and Objects for Blender
 VLC-Addons.org Themes and Extensions for VLC
 KDE-Help.org Support for your KDE Desktop 
 GNOME-Help.org Support for your GNOME Desktop 
 Xfce-Help.org Support for your Xfce Desktop 
openDesktop.orgopenDesktop.org:   Applications   Artwork   Linux Distributions   Documents    Linux42.org    OpenSkillz.com   
- New questions .- Answered question .- Not answered question .- My questions .- Post your question here . 
Go back to the overview page to see other entries
Back to overview

click to vote up

How to use static and shared library in Qt

Programming - Apr 29 2011
not answered
Question:I have created static library and shared library from 2 file:
file mylib.h:
#ifndef MYLIB_H
#define MYLIB_H

class mylib
//De/Construct function
//Add function
inline int add(int a, int b) const;
file mylib.cpp:

mylib::mylib() {}
mylib::~mylib() {}
inline int mylib::add(int a, int b) const
qDebug().operator <<("LCommon::Currently in int add(int, int) const function.");
return a+b;
and the problem is that I dont know how to use "add" function in the 2 libs I've made.
I tried to use static function in this way: I created a simple project:
file use.pro:
QT += core gui
TARGET = use1
LIBS += $$(CPPLIBS)/libmylib.a
INCLUDEPATH += $$(CPPLIBS)/libinclude #contain header file here
SOURCES += main.cpp\
HEADERS += mainwindow.h
and after including mylib.h in mainwindow.h I coded in mainwindow.cpp like this:
int a = mylib::add(6,7);
But this was not successful. The error is:
/mainwindow.cpp:13: error: undefined reference to `mylib::add(int, int) const'
I have searched for a day and got stuck. So please help me to solve this. Thank you very much.

Add answer
Back to overview


 just an idea...

 by Aiwendil on: Apr 30 2011
Score 50%

did you try to give LIBS a gcc systax? Something like: "LIB=-L<path-to-library> -l<libname>"


But sorry..in the end I have no clue about .pro files...

Reply to this

Add comment

Do you have a question?
Post your question here


Copyright 2010-2016 Linux42.org Team  Legal Notice
All rights reserved. Linux42.org is not liable for any content or goods on this site.
You can find our FAQ here.
All contributors are responsible for the lawfulness of their uploads.
Please send us a notice if you spot an ABUSE of the website.
Information about advertising in Linux42.org.
Developers can use our public webservice interface. More information here: public api
For further information or comments on this site, please send us a message