-2

Windows 10 Eclipse IDE for C/C++ Developers Version: Kepler Service Release 2 Build id: 20140224-0627

I'm trying to use imgui. Unfortunately, documentation is pretty shady about how to get it working.

So, in order to get it working, I think I need something called "glad". Whatever it is, the only source of it seems to be some shady-looking one-pager that generates the files for you (found a link to it here).

Anyway, I checked all the boxes I needed (copied from the screenshot from the provided link). I don't understand much about what it is (very roughly), I simply want to get imgui running (ha-ha on me, imgui also needs some other stuff scattered around internet, but it's my next problem, not current).

Anyway, in my new C++ project in eclipse I created a folder "include" and added its path into "C/C++ General -> Paths and Symbols". So when I write "#include "glad/glad.h" in my "test3.cpp" (file with main function, project called test3), I'm ok. But I can't build it because glad.c, which is located in the SAME folder as test3.cpp, has the identical include line, but it gives an error that it can't find it. Sounds like some nonsense to me.

enter image description here

enter image description here

enter image description here

#include "glad/glad.h"
#include <iostream>
using namespace std;
//for those who wanted to copy default hello world program
int main() {
    cout << "!!!Hello World!!!" << endl; // prints !!!Hello World!!!
    return 0;
}
  1. How is this even possible? Looks like a total nonsense to me. They're in the same folder. Test3 sees the file, glad.c doesn't. I tried replacing "<>" in include in glad.c with quotes like in test3.c, same thing. One file works, another doesn't.
  2. What can I do about it?
Ilya
  • 992
  • 7
  • 14
  • 1
    Dont use `<>` for includes that aren't part of the standard. If you look at the code, you can see the include in your file is **not** identical to the include in glad.c – ChrisMM Feb 12 '22 at 21:40
  • @ChrisMM this is how it was in the file. I didn't write it. I changed it to quote marks, nothing changed – Ilya Feb 12 '22 at 21:40
  • `
    ` means search include paths first. `"header"` means search locations relative to the file being compiled first.
    – user4581301 Feb 12 '22 at 21:42
  • @user4581301 I replaced <> with "". Still can't find the file! That's the point! – Ilya Feb 12 '22 at 21:43
  • 2
    I was simply trying to correct what I consider bad advice in the first comment. In the code you have everything correct with the `<>`. Must be a configuration issue. Eclipse separates some of the C options from the C++ rules, perhapes the C++ include paths are correct, but not the C include paths. – user4581301 Feb 12 '22 at 21:46
  • Holy poop! I didn't think about it. It worked. *facepalm*. Well, what could we expect from the person who needs 2 hours to get eclipse working. Thank you. (Added path to C). I didn't even consider it. – Ilya Feb 12 '22 at 21:49
  • Just fired up Eclipse. My copy is about 9 years newer than what you're using (9 years... Consider upgrading if you can so you don't get in a position where you can't easily upgrade) and The C++ include paths are separated from the C include paths. – user4581301 Feb 12 '22 at 21:49
  • lol I installed it 3 hours ago. Wondering why some links take to old versions. oof. "No updates were found" – Ilya Feb 12 '22 at 21:50
  • Unless you're using 32 bit Windows, [this link](https://www.eclipse.org/downloads/download.php?file=/technology/epp/downloads/release/2021-12/R/eclipse-cpp-2021-12-R-win32-x86_64.zip) should get you to the most recent release. [This link should do the same, but with a pretty installer](https://www.eclipse.org/downloads/) – user4581301 Feb 12 '22 at 21:53
  • I tried to compile your code, but my IDE can't extract code from images. Please edit yoiur post with the code (and results) as text. No code posted as text == no help. – Thomas Matthews Feb 12 '22 at 21:53
  • It's literally a default hello world program with 1 line of code added (include). But OK. Problem is already solved anyway tho. – Ilya Feb 12 '22 at 21:55
  • If you're using 32 bit Windows, I think you have to go back to the [September 2018 release](https://www.eclipse.org/downloads/packages/release/2018-09/r) – user4581301 Feb 12 '22 at 21:55
  • no, it's 64-bit windows on a modern pc. I don't know why google sent me a link to ancient eclipse. Will install a new one now. – Ilya Feb 12 '22 at 21:57

1 Answers1

1

Eclipse separates the include paths for C and C++ files. If you have a program combining both C and C++ files, the correct include paths need to be set for both languages.

Navigate to the C/C++ General -> Paths and Symbols -> Includes tab. You will see both languages (and probably Assembly) listed under Languages. Pick the correct language or when adding the path, check the Add to all languages box.

user4581301
  • 33,082
  • 7
  • 33
  • 54