c++openglvisual-studio-2019pangolin

Visual Studio 2019 is importing the (supposedly) wrong headers despite manually specifying include path


I'm using VS2019 to build a visual SLAM project that uses Pangolin for creating visualizations.

I've successfully built Pangolin from source and verified that it works (included examples are running).

Now I'm trying to build the SLAM package which uses Pangolin library headers. In C++ General options I've added the path to Pangolin includes directory (C:/dev/Pangolin/include).

When I start building the project, the compiler picks (wrong) GL\gl.h headers for some reason

C:\Program Files (x86)\Windows Kits\10\Include\10.0.22000.0\um\GL/gl.h(1157,11): error C2144: syntax error: 'void' should be preceded by ';'

Also I'm unsure why GL/gl.h is even being searched for. I have one System.cpp file which imports "pangolin/pangolin.h", which contains the following code

#pragma once

// This header is here for compatibility when building
// all of Pangolin. You are recommended to include only
// what you need, especially when building without a
// particular feature, such as GUI for Video, otherwise
// you'll receive errors.

#include <pangolin/platform.h>

#include <pangolin/display/display.h>
#include <pangolin/display/view.h>
#include <pangolin/display/widgets.h>
#include <pangolin/gl/colour.h>
#include <pangolin/gl/gl.h>
#include <pangolin/gl/gldraw.h>
#include <pangolin/gl/glstate.h>
#include <pangolin/gl/glvbo.h>
#include <pangolin/handler/handler.h>
#include <pangolin/image/image_io.h>
#include <pangolin/plot/plotter.h>
#include <pangolin/var/varextra.h>
#include <pangolin/video/video.h>
#include <pangolin/video/video_input.h>
#include <pangolin/video/video_output.h>

#ifdef _ANDROID_
#  include <pangolin/display/device/display_android.h>
#endif

// Let other libraries headers know about Pangolin
#define HAVE_PANGOLIN

If I remove the path C:/dev/Pangolin/include, the compile fails to find pangolin/pangolin.h and complains (as expected).

Any help in resolving this header issue is much appreciated.


Solution

  • Pangolin's <pangolin/pangolin.h> includes <pangolin/gl/gl.h>, which includes <pangolin/gl/glinclude.h>, which includes <pangolin/gl/glplatform.h>, which includes <GL/gl.h>.

    This is why your compiler is searching for this file.

    Why it fails during compilation is a separate question.