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
        QT       -= gui
TARGET = MyLibrary
TEMPLATE = lib
DEFINES += MYLIBRARY_LIBRARY
SOURCES += mylibrary.cpp
HEADERS += mylibrary.h\
        MyLibrary_global.h \
# Copying to destination folder
DESTDIR = ../../bin
To copy to clipboard, switch view to plain text mode 
  
This one is the .pro of the test application
	
	QT       += core
QT       -= gui
TARGET = TestApp
CONFIG   += console
CONFIG   -= app_bundle
 
TEMPLATE = app
SOURCES += main.cpp
# MeteoGrid Library
LIBS += -L../../bin/libMyLibrary.so
INCLUDEPATH += ../../MyLibrary/MyLibrary
 
 
# Copying to destination folder
DESTDIR = ../../bin
        QT       += core
QT       -= gui
TARGET = TestApp
CONFIG   += console
CONFIG   -= app_bundle
TEMPLATE = app
SOURCES += main.cpp
# MeteoGrid Library
LIBS += -L../../bin/libMyLibrary.so
INCLUDEPATH += ../../MyLibrary/MyLibrary
# Copying to destination folder
DESTDIR = ../../bin
To copy to clipboard, switch view to plain text mode 
  
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[])
{
 
    MyLibraryClass<qint32> xTest (1,1,1);
 
    return a.exec();
}
        #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();
}
To copy to clipboard, switch view to plain text mode 
  
I obtain the error:
	
		
			
			
				main.cpp

.text+0x39): undefined reference to `MyLibraryClass<int>::MyLibraryClass(int, int, int)'
			
		
 
	 
 I'd like to know where's the error, and how can I compile successfully the executable.
Thanks in advance for your replies.
				
			
Bookmarks