Code::Blocks Forums

User forums => Using Code::Blocks => Topic started by: Kaz on May 11, 2021, 04:02:37 pm

Title: Adding include directory
Post by: Kaz on May 11, 2021, 04:02:37 pm
Hello,

I want to enable the line 2 in the photo

Code
#include <glad/gl.h>

by adding the include directory, rather than writing the full path as in the line 1.
And I think I did so, as in the build log, but when I try to open #include file:  'glad/gl.h', I get this warning "Not found".

So can anyone tell me how to do this corrctly?
Title: Re: Adding include directory
Post by: gd_on on May 11, 2021, 04:16:22 pm
I think you should write
Code
#include "glad/gl.h"
<> is normally reserved for standard compiler paths.
Title: Re: Adding include directory
Post by: stahta01 on May 11, 2021, 04:24:35 pm
https://wiki.codeblocks.org/index.php/FAQ-Compiling_(general)#Q:_I_would_like_to_compile_a_project_using_some_non-standard_libraries._How_can_I_indicate_to_CodeBlocks_that_these_libraries_and_include_files_exist.3F (https://wiki.codeblocks.org/index.php/FAQ-Compiling_(general)#Q:_I_would_like_to_compile_a_project_using_some_non-standard_libraries._How_can_I_indicate_to_CodeBlocks_that_these_libraries_and_include_files_exist.3F)

WARNING: Use the "For your project :" section of the directions!

Tim S.
Title: Re: Adding include directory
Post by: stahta01 on May 11, 2021, 04:29:44 pm
I think you should write
Code
#include "glad/gl.h"
<> is normally reserved for standard compiler paths.

The above is likely officially true; but, in practice it tends to mean an Compiler or Third Party include when using angle brackets <>.

Tim S. 
Title: Re: Adding include directory
Post by: Kaz on May 11, 2021, 04:41:00 pm
https://wiki.codeblocks.org/index.php/FAQ-Compiling_(general)#Q:_I_would_like_to_compile_a_project_using_some_non-standard_libraries._How_can_I_indicate_to_CodeBlocks_that_these_libraries_and_include_files_exist.3F (https://wiki.codeblocks.org/index.php/FAQ-Compiling_(general)#Q:_I_would_like_to_compile_a_project_using_some_non-standard_libraries._How_can_I_indicate_to_CodeBlocks_that_these_libraries_and_include_files_exist.3F)

WARNING: Use the "For your project :" section of the directions!

Tim S.

I added the path to both for compiler and linker, but unfortunately still can't open the header file.

I also tried replacing "" with <>, which didn't make a difference either.
Title: Re: Adding include directory
Post by: stahta01 on May 11, 2021, 04:48:58 pm
Post the "build log" Do not post the "Build Messages"!

Edit: Add FAQ link https://wiki.codeblocks.org/index.php/FAQ-Compiling_(errors)#Q:_How_do_I_troubleshoot_a_compiler_problem.3F (https://wiki.codeblocks.org/index.php/FAQ-Compiling_(errors)#Q:_How_do_I_troubleshoot_a_compiler_problem.3F)

Tim S.
Title: Re: Adding include directory
Post by: oBFusCATed on May 11, 2021, 04:53:59 pm
Post the "build log" Do not post the "Build Messages"!
Note: Also you can "right click -> copy" instead of posting screen shots :)
Title: Re: Adding include directory
Post by: Kaz on May 11, 2021, 05:24:58 pm
Here is the build log. I've notced that it compiles without errors, but it's just that I can't open the header filefrom code blocks unless I write the full path. Does this mean that it's no problem apart from the inconvenience?...



-------------- Build: Debug in 10MayTest (compiler: GNU GCC Compiler)---------------

g++ -Wall -fexceptions -g -I/home/kazuya/vcpkg/buildtrees/glfw3/src/3.3.3-47325b0495.clean/deps/ -c /home/kazuya/Documents/10MayTest/main.cpp -o obj/Debug/main.o
g++ -L/home/kazuya/vcpkg/buildtrees/glfw3/src/3.3.3-47325b0495.clean/deps/ -o bin/Debug/10MayTest obj/Debug/main.o   
Output file is bin/Debug/10MayTest with size 91.13 KB
Process terminated with status 0 (0 minute(s), 0 second(s))
0 error(s), 0 warning(s) (0 minute(s), 0 second(s))
 
Title: Re: Adding include directory
Post by: gd_on on May 11, 2021, 05:35:20 pm
If you simply right click on the line containing #include "glad/gl.h", you should see a popup with open 'glad/gl.h'
Title: Re: Adding include directory
Post by: Kaz on May 12, 2021, 12:30:40 pm
Quote
If you simply right click on the line containing #include "glad/gl.h", you should see a popup with open 'glad/gl.h'

Somehow it doesn't work, to repeat myself, unless I type with the full path.
However, now I've realised that this might be just slight inconvenience with no serious consequences, so I'd like to leave this for now.

Thank you very much for the answers, though.
Title: Re: Adding include directory
Post by: gaiusbonus on May 12, 2021, 12:43:01 pm
did you add a path to compilers serach directories?

In the project build options you have to add the search directory like this:
../../yourLocalPathToGlad/glad/include
Title: Re: Adding include directory
Post by: oBFusCATed on May 12, 2021, 01:18:55 pm
Here is the build log. I've notced that it compiles without errors, but it's just that I can't open the header filefrom code blocks unless I write the full path. Does this mean that it's no problem apart from the inconvenience?...
It is a bug if you've set the search path in the project -> build options -> search directories.
Where exactly have you added the path?
Title: Re: Adding include directory
Post by: gaiusbonus on May 12, 2021, 01:51:52 pm
What do you mean with "It is a bug"? A mistake?
There may be other ways to get to Rome but this is the one I use successfully.
If I remember right, I used a book from Joey de Vries when I startet with openGL and did it the same way since then.
Title: Re: Adding include directory
Post by: oBFusCATed on May 12, 2021, 04:24:46 pm
What do you mean with "It is a bug"? A mistake?
I mean that if the "open include file" feature of the IDE doesn't work, but compilation from the IDE works, then it is most probably a bug in the IDE and it should be possible to fix it.