Thanks for your reply. It didn't work for me, but I've done a similar thing with the QtCreator.
1. New Project:
Console
Name 'LibTest'
Folder 'E:\Project\Qt', Kit 'Desktop Qt 5.7.0 MinGW 32bit'
2. New Project
C++ library
static linking
Name 'MyLib'
Folder 'E:\Project\Qt\LibTest'
Kit 'Desktop Qt 5.7.0 MinGW 32bit'
Modules 'QtCore'
3. Added Method (mylib.h)
#ifndef MYLIB_H
#define MYLIB_H
class MyLib {
public:
MyLib();
int Test() { return 123; }
};
#endif // MYLIB_H
#ifndef MYLIB_H
#define MYLIB_H
class MyLib {
public:
MyLib();
int Test() { return 123; }
};
#endif // MYLIB_H
To copy to clipboard, switch view to plain text mode
4. Adding existing subfolder to project 'LibTest' via context menu & dialog added to 'LibTest.pro':
SUBDIRS += \
MyLib/MyLib.pro
HEADERS += \
MyLib/mylib.h
SUBDIRS += \
MyLib/MyLib.pro
HEADERS += \
MyLib/mylib.h
To copy to clipboard, switch view to plain text mode
5. Changed main function to test MyLib::Test() method call
#include <QCoreApplication>
#include <QTextStream>
#include "MyLib/mylib.h"
int main(int argc, char *argv[]) {
MyLib instance;
stream << "MyLib::Test returned: " << instance.Test() << endl;
return 0;
}
#include <QCoreApplication>
#include <QTextStream>
#include "MyLib/mylib.h"
int main(int argc, char *argv[]) {
QCoreApplication a(argc, argv);
MyLib instance;
QTextStream stream(stdout);
stream << "MyLib::Test returned: " << instance.Test() << endl;
return 0;
}
To copy to clipboard, switch view to plain text mode
6. Running programm was successfull
Output: MyLib::Test returned: 123
So my problem is partially solved, but it seems, that adding an internal library via GUI is not working.
Added after 1 37 minutes:
Sorry, I found the problem: I've used the wrong project type!
SUBDIRS - handling dependencies
Now the dropdown lists are filled.
Bookmarks