PDA

View Full Version : MyLibrary - Install to /usr/lib



DaneAU
15th May 2011, 11:46
Hello,

I am writing an API at the moment and am doing so with some success. I can build it all fine, however i am wondering in my project file, is there a way to specify where the lib or application should be installed. So i don't have to specify the TARGET and build with super user permissions.

I want people to be able to complile my library anywhere with the following


qmake
make
sudo make install


So yea, not sure how to specify the install path. Just as an example project file. I may have something like the following



TEMPLATE = lib
TARGET = example
DEPENDPATH += .
INCLUDEPATH += .
DESTDIR = build

VERSION = 1.0.0

MOC_DIR = mocs
OBJECTS_DIR = obj

# Input
HEADERS += example.h
SOURCES += example.cpp

So the created .so is found in the build directory. So if i now execute make install i wish to install the .so into /usr/lib/ as libexample.so


Any advice

Cheers

wysota
15th May 2011, 11:49
Add the following to your project:
unix {
target.path = /usr/lib
INSTALLS += target
}

DaneAU
15th May 2011, 11:59
Wow lol, why didn't i ask earlier that was a pinch :)

Thanks a bunch for responding so quickly mate :p

dholliday
16th May 2011, 12:46
I don't know if this is a better solution but I add this to my pro file.

QMAKE_RPATHDIR=$$pathtomylibrary

I used this because I didn't want to leave redundat libraries on people computer. So they could just delete the build folder and everything would be gone.
If you want to know how to get the path to your library I used the variable $${OUT_PWD}.
But because my project was a sub project it got a little confusing so I had the following code (Where publish is where all my compiled components go)

DESTDIR = ../Publish/
myfile=$${OUT_PWD}.txt
buildfolder=$$dirname(myfile)
buildfolder=$${buildfolder}/Publish
QMAKE_RPATHDIR+=$$buildfolder

Hope this gives you a good alternative. If you want to see the values of the variables you can out put them by adding

message($$buildfolder)

to your pro file.

Also NOTE: that you place these in the pro file of the application that needs the library.

DaneAU
25th September 2011, 20:43
Thanks for the information dholliday, i got my project file configured now and all is well :)