I am using Visual Studio 2022 and its build tools in Windows. In particular, I use Visual Studio with x64 Native Tools Command Prompt for VS 2022 to open VS and use its integrated CMake and compiler cl.exe. I downloaded libigl from the github repository and used the CMakeLists.txt to have all the necessary libraries.
I had no problem in building the basic examples. However, the problem comes when viewing the resultant mesh with viewer. We have to keep in mind that there are some dependencies of the igl::opengl::glfw::Viewer (OpenGL, glad and GLFW). For that, I downloaded GLFW aside.
Now, the difference for this tutorial is that in order to visualize the mesh I have to do the linking with GLFW and I am not sure how to do it correctly.
The tutorial is the following:
#include <igl/readOFF.h>
#include <igl/opengl/glfw/Viewer.h>
Eigen::MatrixXd V;
Eigen::MatrixXi F;
int main(int argc, char *argv[])
{
// Load a mesh in OFF format
igl::readOFF(TUTORIAL_SHARED_PATH "/bunny.off", V, F);
// Plot the mesh
igl::opengl::glfw::Viewer viewer;
viewer.data().set_mesh(V, F);
viewer.launch();
}
In this case, I think I have to use GLFW as a DLL, right? Or as a static library? I used it as a DLL so I used specifically the glfw3dll.lib file. Doing some research I realised that I also have to define the GLFW_DLL macro before any inclusion of the GLFW header but I am not sure where I have to put it, in the file that has #include <GLFW/glfw3.h> or in my main.cpp? I don´t know either if I did the linking well.
In short, I wrote the following:
cl /EHsc tutorial/102_DrawMesh/main.cpp build/_deps/glad-src/src/glad.c
(I also included the necessary libraries)
/I "E:\GLFW\include\GLFW" glfw3dll.lib /link /LIBPATH:"E:\GLFW\lib-vc2022"
I run it and I get:
Compilador de optimización de C/C++ de Microsoft (R) versión 19.34.31935 para x64 (C) Microsoft Corporation. Todos los derechos reservados.
main.cpp
Generating code...
Compiling...
glad.c
Generating code...
Microsoft (R) Incremental Linker Version 14.34.31935.0
Copyright (C) Microsoft Corporation. All rights reserved.
/out:main.exe
/LIBPATH:E:\GLFW\lib-vc2022
main.obj
glad.obj
glfw3dll.lib
However, when I try to open the main.obj, the viewer opens but it is not able to plot it, it closes all of a sudden.