0

I did a CMake project, using ImGui and GLFW libraries, and everything works fine and run correctly.

But when I try to create a new one with the same CMakeLists.txt and same including of headers, there are two E1696 errors:

  • cannot open source file "imgui_impl_glfw.h"
  • cannot open source file "imgui_impl_opengl3.h"

My CMakeLists.txt from not-working project:

find_package(imgui CONFIG REQUIRED)
find_package(glfw3 3.3 CONFIG REQUIRED)
find_package(gl3w CONFIG REQUIRED)
find_package(OpenGL REQUIRED COMPONENTS OpenGL)

add_executable(main main.cpp)

target_link_libraries(main PRIVATE unofficial::gl3w::gl3w)
target_link_libraries(main
PRIVATE imgui::imgui)
target_link_libraries(main
PRIVATE glfw)
target_link_libraries(main
PRIVATE OpenGL::GL)

How I include libraries:

#include <stdio.h> 
#include <imgui.h> 
#include <imgui_impl_glfw.h> 
#include <imgui_impl_opengl3.h> 
#include <GL/gl3w.h> 
#define GL_SILENCE_DEPRECATION 
#if defined(IMGUI_IMPL_OPENGL_ES2) 
#include <GLES2/gl2.h> 
#endif #define GLFW_INCLUDE_NONE #include <GLFW/glfw3.h>

Downloaded triplets are x64 and build is in x65-Debug mode.

I checked all CMake and vcpkg global parameters in systems and restore project cache, because I thought problem might be in broken vcpkg roots, but it doesn't help. I remake project several times, from VS template for CMake project and as just a folder which I opened in Visual Studio, but results are still the same.

drescherjm
  • 10,365
  • 5
  • 44
  • 64
su-mrak
  • 1
  • 1
  • ***I did a CMake project, using ImGui and GLFW libraries, and everything works fine and run correctly.*** My guess is you updated vcpkg and that changed the features you had installed for imgui. I expect if you did a clean build for the first project it would break. – drescherjm Jun 13 '23 at 18:09
  • And what I meant is expect you compiled `imgui` a second time in `vcpkg` and did not enable the glfw-binding feature of imgui defined here in the vcpkg portfile: [https://github.com/microsoft/vcpkg/blob/master/ports/imgui/portfile.cmake#L31](https://github.com/microsoft/vcpkg/blob/master/ports/imgui/portfile.cmake#L31) – drescherjm Jun 13 '23 at 19:54
  • @drescherjm, thank you for your answer! I checked profile.cmake in my vcpkg folder, and it is the same as in github vcpkg repo. I also copied all files from non-working folder, created a new one and rebuild the project in VS from this new folder. As a result: everything is fine... It's really strange for me, why it was broken only in one of them. – su-mrak Jun 14 '23 at 17:05

0 Answers0