Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Including a self-made library into another project
Forum Updated to NodeBB v4.3 + New Features

Including a self-made library into another project

Scheduled Pinned Locked Moved General and Desktop
2 Posts 2 Posters 1.9k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • J Offline
    J Offline
    jepessen
    wrote on last edited by
    #1

    Hi.
    I'm trying to create a program with one library and one executable that invokes that library.

    At first, I've created one folder for the application, and then three subfolders, one for a test executable project, one for the library project and one that's the path in which both library and executable are copied.

    APP
    |
    |- bin
    |- MyLibrary
    | |- MyLibrary <== .pro and sources
    | |- MyLibrary-build-desktop
    |- TestApp
    | |- TestApp <== .pro and sources
    | |- TestApp-build-desktop

    This is the .pro of the library

    @QT -= gui
    TARGET = MyLibrary
    TEMPLATE = lib
    DEFINES += MYLIBRARY_LIBRARY

    SOURCES += mylibrary.cpp
    HEADERS += mylibrary.h
    MyLibrary_global.h \

    Copying to destination folder

    DESTDIR = ../../bin[/CODE]

    This one is the .pro of the test application
    [CODE]QT += core
    QT -= gui
    TARGET = TestApp
    CONFIG += console
    CONFIG -= app_bundle

    TEMPLATE = app
    SOURCES += main.cpp

    MyLibrary Library

    LIBS += -L../../bin/libMyLibrary.so
    INCLUDEPATH += ../../MyLibrary/MyLibrary

    Copying to destination folder

    DESTDIR = ../../bin@

    When I compile the library, it's successfully copied into the bin directory.

    If I include the mylibrary.h header into the test application, it finds it and it compiles.
    But, if I try to use the class defined in my library

    @#include <QtCore/QCoreApplication>

    #include "mylibrary.h"

    int main(int argc, char *argv[])
    {
    QCoreApplication a(argc, argv);

    MyLibraryClass<qint32> xTest (1,1,1);
    
    return a.exec&#40;&#41;;
    

    }@

    I obtain the error:

    [QUOTE]main.cpp:(.text+0x39): undefined reference to `MyLibraryClass<int>::MyLibraryClass(int, int, int)'[/QUOTE]

    I'd like to know where's the error, and how can I compile successfully the executable.

    Thanks in advance for your replies.

    1 Reply Last reply
    0
    • C Offline
      C Offline
      cincirin
      wrote on last edited by
      #2

      LIBS += -L../../bin/ -lMyLibrary

      1 Reply Last reply
      0

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved