c++visual-studio-2019gmsh

Unable to use gmsh from Visual Studio C++


  1. I downloaded the sdk and ran the Windows related commands described here.
  2. Then I created a new VC++ project and copied the contents of a tutorial file included with that sdk (t1.cpp).
  3. There were compile time errors, which I fixed by including the path to gmsh.h in the include settings found in projcet->Properties->Configuration Properties->C/C++->General->Additional Include Directories.
  4. I also included path to the gmsh.lib file at projcet->Properties->Configuration Properties->Linker->General->Additional Libraries Directories.

Still I am getting the below error while trying to build the project:

LNK2019:    unresolved external symbol gmshFree referenced in function "int __cdecl gmsh::model::geo::addCurveLoop(class std::vector<int,class std::allocator<int> > const &,int,bool)" (?addCurveLoop@geo@model@gmsh@@YAHAEBV?$vector@HV?$allocator@H@std@@@std@@H_N@Z)

Please say what I am missing here. I am running Microsoft Visual Studio Community 2019 (Version 16.10.4) on Windows 10.


Solution

  • Did you add #include "gmsh.h " and add gmsh.lib in Configuration Properties > Linker > Input? For more information, you could refer to the document: Create a client app that uses the DLL.