Unable to build t1.cpp example from Windows 64 SDK under Visual Studio Code (MSVC), Windows 10 native environment.
Hi,
I am trying to use the Windows 64bit SDK download from here: http://gmsh.info/bin/Windows/gmsh-git-Windows64-sdk.zip in order to build an application of mine using the gmsh API on Windows 10, building the application on Visual Studio Code (MSVC) via cmake.
After several unsuccessful trials, I went one step back: I am now trying to compile the t1.cpp example present in: share\doc\gmsh\tutorial\c++
by following the instructions included in the README.txt:
-
If your C++ compiler does not have a compatible ABI and if there are no compatibility flags available, you can rename
gmsh.h_cwrap' as
gmsh.h': this implementation redefines the C++ API in terms of the C API. Using this header will lead to (slightly) reduced performance compared to using the native Gmsh C++ API from the original `gmsh.h' header, as it entails additional data copies between this C++ wrapper, the C API and the native C++ code.For example, the Windows SDK is currently compiled using the GNU Compiler Collection (GCC). To compile a C++ example with Microsoft Visual Studio 2017 in the Visual Studio shell and run it, you would do:
C:\gmsh-git-Windows64-sdk> ren include\gmsh.h_cwrap gmsh.h C:\gmsh-git-Windows64-sdk> cl /Iinclude share\doc\gmsh\tutorial\c++\t1.cpp lib\gmsh.lib C:\gmsh-git-Windows64-sdk> cd lib C:\gmsh-git-Windows64-sdk\lib> ..\t1.exe
But it does not work.
The linker produces these type of errors:
...
Microsoft (R) Incremental Linker Version 14.26.28805.0 Copyright (C) Microsoft Corporation. All rights reserved.
/out:t1.exe
t1.obj
lib\gmsh.lib
t1.obj : error LNK2019: unresolved external symbol _gmshFree referenced in function "int __cdecl gmsh::model::geo::addCurveLoop(class std::vector<int,class std::allocator > const &,int)" (?addCurveLoop@geo@model@gmsh@@YAHABV?vector@HV?
allocator@H@std@@@std@@H@Z)
t1.obj : error LNK2019: unresolved external symbol _gmshMalloc referenced in function "void __cdecl gmsh::vector2ptr(class std::vector<int,class std::allocator > const &,int * *,unsigned int *)" (??vector2ptr@H@gmsh@@YAXABV?
vector@HV?$allocator@H@std@@@std@@PAPAHPAI@Z)
...
I am not using MinGW, nor Cygwin, nor WSL: just the native Windows 10 environment.
Do you have any suggestion?
Thanks
Best regards,
Erik