Error LNK2019 using QApplication
guiserguez opened this issue · 0 comments
guiserguez commented
Hello Mr Guanzhou!
Have you been able to use the QGis class "QApplication" in any project?
I´m trying to create a program using your library and QT 5.7 but the next error show up when I execute it:
1>------ Build started: Project: QGisTest, Configuration: Release x64 ------
1> moc_qgsapplication.cpp
1> Creating library C:\Users\GRODRIGUEZ\Documents\Visual Studio 2015\Projects\QGisTest\x64\Release\QGisTest.lib and object C:\Users\GRODRIGUEZ\Documents\Visual Studio 2015\Projects\QGisTest\x64\Release\QGisTest.exp
1>moc_qgsapplication.obj : error LNK2019: unresolved external symbol "private: static class QMap<class QString,class QString> QgsApplication::mSystemEnvVars21800" (?mSystemEnvVars21800@QgsApplication@@0V?$QMap@VQString@@V1@@@A) referenced in function "public: static class QMap<class QString,class QString> __cdecl QgsApplication::systemEnvVars(void)" (?systemEnvVars@QgsApplication@@SA?AV?$QMap@VQString@@V1@@@XZ)
1>main.obj : error LNK2001: unresolved external symbol "private: static class QMap<class QString,class QString> QgsApplication::mSystemEnvVars21800" (?mSystemEnvVars21800@QgsApplication@@0V?$QMap@VQString@@V1@@@A)
1>moc_qgsapplication.obj : error LNK2019: unresolved external symbol "private: static bool QgsApplication::mRunningFromBuildDir21800" (?mRunningFromBuildDir21800@QgsApplication@@0_NA) referenced in function "public: static bool __cdecl QgsApplication::isRunningFromBuildDir(void)" (?isRunningFromBuildDir@QgsApplication@@SA_NXZ)
1>main.obj : error LNK2001: unresolved external symbol "private: static bool QgsApplication::mRunningFromBuildDir21800" (?mRunningFromBuildDir21800@QgsApplication@@0_NA)
1>moc_qgsapplication.obj : error LNK2019: unresolved external symbol "private: static class QString QgsApplication::mBuildSourcePath21800" (?mBuildSourcePath21800@QgsApplication@@0VQString@@A) referenced in function "public: static class QString __cdecl QgsApplication::buildSourcePath(void)" (?buildSourcePath@QgsApplication@@SA?AVQString@@XZ)
1>main.obj : error LNK2001: unresolved external symbol "private: static class QString QgsApplication::mBuildSourcePath21800" (?mBuildSourcePath21800@QgsApplication@@0VQString@@A)
1>moc_qgsapplication.obj : error LNK2019: unresolved external symbol "private: static class QString QgsApplication::mCfgIntDir21800" (?mCfgIntDir21800@QgsApplication@@0VQString@@A) referenced in function "public: static class QString __cdecl QgsApplication::cfgIntDir(void)" (?cfgIntDir@QgsApplication@@SA?AVQString@@XZ)
1>main.obj : error LNK2001: unresolved external symbol "private: static class QString QgsApplication::mCfgIntDir21800" (?mCfgIntDir21800@QgsApplication@@0VQString@@A)
1>moc_qgsapplication.obj : error LNK2019: unresolved external symbol "private: static class QString QgsApplication::mBuildOutputPath21800" (?mBuildOutputPath21800@QgsApplication@@0VQString@@A) referenced in function "public: static class QString __cdecl QgsApplication::buildOutputPath(void)" (?buildOutputPath@QgsApplication@@SA?AVQString@@XZ)
1>main.obj : error LNK2001: unresolved external symbol "private: static class QString QgsApplication::mBuildOutputPath21800" (?mBuildOutputPath21800@QgsApplication@@0VQString@@A)
1>moc_qgsapplication.obj : error LNK2019: unresolved external symbol "private: static class QStringList QgsApplication::mGdalSkipList21800" (?mGdalSkipList21800@QgsApplication@@0VQStringList@@A) referenced in function "public: static class QStringList __cdecl QgsApplication::skippedGdalDrivers(void)" (?skippedGdalDrivers@QgsApplication@@SA?AVQStringList@@XZ)
1>main.obj : error LNK2001: unresolved external symbol "private: static class QStringList QgsApplication::mGdalSkipList21800" (?mGdalSkipList21800@QgsApplication@@0VQStringList@@A)
1>moc_qgsapplication.obj : error LNK2019: unresolved external symbol "private: static int QgsApplication::mMaxThreads21800" (?mMaxThreads21800@QgsApplication@@0HA) referenced in function "public: static int __cdecl QgsApplication::maxThreads(void)" (?maxThreads@QgsApplication@@SAHXZ)
1>main.obj : error LNK2001: unresolved external symbol "private: static int QgsApplication::mMaxThreads21800" (?mMaxThreads21800@QgsApplication@@0HA)
1>C:\Users\GRODRIGUEZ\Documents\Visual Studio 2015\Projects\QGisTest\x64\Release\\QGisTest.exe : fatal error LNK1120: 7 unresolved externals
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
I'm using VS2015 x64, W10 and QT 5.7 and my main.cpp just contains the following lines:
#define CORE_EXPORT __declspec(dllexport)
#include "QGisTest.h"
#include <QtWidgets/QApplication>
#include <qgsapplication.h>
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
QGisTest w;
w.show();
return a.exec();
}
I also added to the project your"moc_qgsapplication.cpp" and wrote the line "#define CORE_EXPORT __declspec(dllexport)" to avoid other compilation problems and linked to the project the Qgis and QT 5.7 libs.
Thanks in advance!