how to run code in qt?
hi,I am trying to embed gmsh in Qt,but here I got problems ! First I add below code in gmshGlobal.cpp
GMSH_API int GmshMainQt(int argc, char** argv) {
new GModel();
GmshInitialize(argc, argv, true, true);
OpenProject(GModel::current()->getFileName());
for(unsigned int i = 1; i < CTX::instance()->files.size(); i++) {
if(CTX::instance()->files[i] == "-new") {
GModel::current()->setVisibility(0);
new GModel();
}
else
MergeFile(CTX::instance()->files[i]);
}
QApplication app(argc, argv);
QGui::instance(argc, argv);
return app.exec();
}
the modify gmshGlobal.h
#if defined(GMSH_DLL)
#if defined(GMSH_DLL_EXPORT)
#define GMSH_API __declspec(dllexport)
#else
#define GMSH_API __declspec(dllimport)
#endif
#else
#define GMSH_API
#endif
GMSH_API int GmshMainBatch(int argc, char **argv);
GMSH_API int GmshMainFLTK(int argc, char **argv);
GMSH_API int GmshMainQt(int argc, char **argv);
#endif
then modify common/main.cpp:
#include <stdlib.h>
#include "GmshGlobal.h"
#include "GmshMessage.h"
#include "GModel.h"
#include "CommandLine.h"
#include "OpenFile.h"
#include "Context.h"
#include "QGui.h"
#include <QApplication>
int main(int argc, char *argv[])
{
return GmshMainQt(argc, argv);
//return GmshMainBatch(argc, argv);
}
and add utils/qt QGui.h QGui.cpp ,GrahpicWindow and GLWidget to common. then I use camke to rebuild the source code ,my c++ compiler is visual stuido 2019 professional. I configure qt lib and so on. but here I got problem like this:
LNK2019 unresolved external symbol "public: __cdecl drawContext::drawContext(class openglWindow *,class drawTransform *)" (??0drawContext@@QEAA@PEAVopenglWindow@@PEAVdrawTransform@@@Z),the symbol in function "public: __cdecl GLWidget::GLWidget(class QWidget *)" (??0GLWidget@@QEAA@PEAVQWidget@@@Z) was cited.
shared D:\test\gmsh-cmake\gmsh-4.5.6-source\build\GLWidget.obj 1
Any idea??? Thanks!!!
Edited by zhu