Installing my own library to my Linux system with Qt Creator



  • Hi everyone!

    I'm currently developing a C++ library using Qt Creator. I'm using the Libraries -> C++ Library mode in Creator.

    When I compile the project, I can see the .a library file in the build directory. A @make install@ in this directory copies the library to the appropriate system folder; /usr/local/lib in my case. Now, if I got this right, I'm also supposed to copy the header files to /usr/include/, or any other folder that my compiler is aware of.

    Is there a way to say to Qt Creator that when I compile/install the library, I want to actually install the library system-wide?

    I hope my question is clear, and if it's not, please tell me how I can clarify.

    Thanks,





  • Thanks for the answer.

    I looked at the armadillo library to see how it did what I wanted to do, and I found a way to do it with qmake. I simply added the following lines to my .pro file:

    @QMAKE_STRIP = echo

    inc1.path = /usr/local/include
    inc1.files = dynamica

    inc2.path = /usr/local/include/dynamica_bits
    inc2.files = *.h

    INSTALLS += inc1 inc2@

    where dynamica is the name of my library.

    Thanks!



  • Hello again!

    The library has progressed some more and, consequently, new issues have arisen. Because of the growing number of files, I decided to use .pri files to organize the project (the entire source is available "here":http://code.google.com/p/libdynamica/source/browse/ ).

    Now, when I install the library, I copy over the headers to /usr/local/include. How does one usually deal with this?

    As you can see from my .pro file

    @
    #---------------------------------------------------#

    Project created by QtCreator 2012-06-14T11:33:08

    #---------------------------------------------------#

    --------------------------------------------------#

    Main project configuration

    --------------------------------------------------#

    QT -= core gui

    TARGET = dynamica
    TEMPLATE = lib
    CONFIG += staticlib create_prl

    --------------------------------------------------#

    Compilation parameters

    --------------------------------------------------#

    We need -std=c++11 to use initializer lists in Armadillo.

    We require g++ >= 4.7.

    !! WARNING: PLATFORM-DEPENDANT CODE !!

    GCCVERSION = $$system(g++ --version | grep -oe "[0-9].[0-9]")

    defineReplace(testVersion){
    if $$GCCVERSION < 4.7 {
    error(You are not using the a supported g++ version.)
    }
    }
    QMAKE_CXXFLAGS += -std=c++11

    --------------------------------------------------#

    C++ Headers and Sources

    --------------------------------------------------#

    include(ode.pri)
    include(roots.pri)
    include(utilities.pri)
    include(chaos.pri)
    include(special_functions.pri)

    OTHER_FILES +=
    dynamica
    Doxyfile \

    --------------------------------------------------#

    Libraries

    --------------------------------------------------#

    unix:!symbian|win32: LIBS += -larmadillo -lgfortran

    --------------------------------------------------#

    Installation Configuration

    --------------------------------------------------#

    QMAKE_STRIP = echo

    inc1.path = /usr/local/include
    inc1.files = dynamica

    inc2.path = /usr/local/include/dynamica_bits
    inc2.files +=
    chaos/.h
    ode/
    .h
    roots/.h
    special_functions/
    .h
    utilities/*.h\

    INSTALLS += inc1 inc2

    unix:!symbian {
    maemo5 {
    target.path = /opt/usr/lib
    } else {
    target.path = /usr/local/lib
    }
    INSTALLS += target
    }

    HEADERS +=
    docs.h
    @

    I copy all headers to the same folder, effectively flattening the folder structure during installation. However, in my development directories, the header #include each other using the flat folder structure (which seems like an odd way to do it) although in the development directories, the folder structure is complex.

    Sorry for the long question. I'll try to boil it down to two simple questions.

    When installing a header library, do you can flatten out the original directory structure or do you keep the same directory structure?

    I'd vote for the second one, albeit the question now becomes: how does one configure qmake to preserve directory structure? Sure, I could add a INSTALLS for each directory, but that seems like an inelegant solution.

    Thanks!


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.