Problems to compile a static library project
-
Hi all,
I am new on this forum, and don't know if the post is at the good place. Let me know if i am wrong writing in this section.Today, i want to compile a static library with Qt. I started with a light sample code. I have a single class containing a QString attribute.
When i compile this little project, i get a single error :
QString : no such file or directoryI really don't know why this error happened. I also trie to add QT += core to the .pro file with no more result.
Here is the sample code :
@
#ifndef SAMPLELIBRARY_H
#define SAMPLELIBRARY_H
#include <QString>
class SampleLibrary
{
private:
QString s;
public:
SampleLibrary();
};
#endif
@
@
#include "SampleLibrary.h"
SampleLibrary::SampleLibrary()
{
}
@And the .pro file :
@
QT -= gui
TARGET = SampleLibrary
TEMPLATE = lib
CONFIG = staticlib
SOURCES += SampleLibrary.cpp
HEADERS += SampleLibrary.h
@Someone here could help to resolve it ?
Regards,
Jhx76 -
Remove
#include <QString>
andbq. add QT += core to the .pro
-
Hi and welcome to devnet,
[quote author="MarianMMX" date="1384286077"]Remove
#include <QString>
[/quote]Why remove the include ? How would he be able to use QString in that case ?
What OS. Qt version and IDE are you using ?
-
Hi, thanks for your replies. I am using ubuntu 13.04 and Qt4.8.5.
-
And how do you build your library ?
-
Hi guys,
Sorry, i am late to reply ...To build the library, i just created a C++ Library project with QtCreator (the last version avaible).
I added the "CONFIG = staticlib" to the project file to specify i want to build it as a static library (was configured to build a dynamic one into .so files).The library provides many classes to support the xPL protocol (see http://xplproject.org.uk fore more informations about xPL project).
Face to the difficulties i encountered to build it, i sarted a "test project", that i linked you in the above messages.
I tried to build it from QtCreator.I also tried to add
@
QT += core
@
to the project file, but it doesn't fix the problem.Thank you very much for your replies.
Have a good evening ! :)
Jhx76 -
Hi again !
I just found my error !
I had to change :
@
CONFIG = staticlib
@into
@
CONFIG += staticlib
@And it performs the build correctly ! :)
Thanks for help
Jhx76 -
Ok, I see what your problem was.
CONFIG contains already a base set of values. Using = you emptied it thus removing qt from it so it would use it to build your library