Link error on Visual Studio 2022: can't open ilg::opengl_glfw_imgui.obj
Describe your issue
I'm using MSVC on Visual Studio 2022 to compile a libigl program that uses the imgui plugin. I'm geting LINK : fatal error LNK1104: can't oper file 'igl::opengl_glfw_imgui.obj'.
I already set igl::opengl_glfw_imgui among the additional dependencies of the linker. I also set LIBIGL_WITH_OPENGL_GLFW_IMGUI among the preprocessor flags. I'm using VS only to compile: CMake is not involved.
Checklist
- [x] I have read the bug report page
- [ ] CMake issue: I have tried with a fresh clone/empty build directory
Platform
- [x] Windows
- [ ] macOS Intel
- [ ] macOS Arm (e.g., M1, M2)
- [ ] Linux
This particular error message is showing up because igl::opengl_glfw_imgui.obj is a CMake target, not static compiled .obj file like msvc expects when you pass it something in the additional dependencies.
If you absolutely need to manually link, try removing this line and finding the files you need to link for imgui, opengl, and glfw. You can try compiling and it will tell you what symbols it is missing at link time in the log.
What I would generally suggest instead when using msvc is using vcpkg. If you create a vcpkg.json in your project directory with the following
{
"name": "test",
"dependencies: [
{
"name": "libigl",
"features": [ "imgui" ]
}
],
"builtin-baseline": "47364fbc300756f64f7876b549d9422d5f3ec0d3"
}
And you go Project->Properties->vcpkg and enable 'Use Vcpkg', 'Use Vcpkg Manifest', 'Install Vcpkg Dependencies', and 'Use AutoLink', vcpkg will automatically be triggered when building and automatically link in everything you need.