I created a shared library with Qt Creator (compiler MSVC2010 32bits) to make some operations with xml files (when I had to select the modules, I checked QtCore, QtXml and QtXmlPatterns).
Here is the code of the lib :
Header :
#ifndef CONVERTERSHARED_H
#define CONVERTERSHARED_H
#include "convertershared_global.h" //created automatically by Qt
#include <QString>
class CONVERTERSHAREDSHARED_EXPORT ConverterShared
{
public:
ConverterShared();
bool convert(QString inFileName);
};
#endif // CONVERTERSHARED_H
.cpp
#include "convertershared.h"
#include <QFile>
#include <QFileInfo>
#include <QDir>
#include <QXmlStreamWriter>
#include <QXmlStreamReader>
#include <QDomDocument>
#include <QMap>
#include <iostream>
#include <fstream>
using namespace std;
ConverterShared::ConverterShared()
{
}
bool ConverterShared::convert(QString inFileName)
{
//process...
}
So it creates a .lib, and a .dll.
When I use this lib in a Qt project (including paths to includes, libraries in .pro, putting .dll in the exe directory), all is fine, I can create an instance of ConverterShared and use the convert function.
My problem is to use it in a Visual Studio (C++ 2010) project which doesn't use Qt. So in the properties of the project, I added :
in C/C++ -> General -> Additional Include Directories -> path/to/convertershared.h (contains convertershared_global.h too)
in Libraries -> General -> Additional Dependencies -> ConverterShared.lib (tested with path/ConverterShared.lib and without path)
in Libraries ->General -> Additional Libraries Directories -> path/to/lib
Then, in a .cpp file, it finds convertershared.h so I include it but when I compile, I get the error :
Cannot open include file QtCore/qglobal.h: No such file or directory
(and then IntelliSense cannot open source file "QtCore/qglobal.h", "QString")
So how to correct that and use my Qt lib in a Visual project which doesn't use Qt (the PC on which the final Visual project is compiled doesn't necessarly have Qt installed)?