[SOLVED] Broken Header Include Location

Programming, for all ages and all languages.
Post Reply
User avatar
Octacone
Member
Member
Posts: 1138
Joined: Fri Aug 07, 2015 6:13 am

[SOLVED] Broken Header Include Location

Post by Octacone »

Language: C
Compiler: i386 GCC Cross Compiler
Operating System: Linux Ubuntu Latest

I have a big problem. I can't include header files using #include "../Folder/Something/FileIwantToInclude.h"
I am constantly getting:

Code: Select all

fatal error: ../Headers/Kernel/FileIwantToInclude.h: No such file or directory
I am loosing my mind. This used to work...
Also this is my folder tree type:

Code: Select all

Basic OS
  ˇHeaders
    ˇ Kernel
        ˘ FileIwantToInclude.h
Does anybody know what is going on?
Last edited by Octacone on Wed Sep 28, 2016 7:35 am, edited 1 time in total.
OS: Basic OS
About: 32 Bit Monolithic Kernel Written in C++ and Assembly, Custom FAT 32 Bootloader
Octocontrabass
Member
Member
Posts: 5513
Joined: Mon Mar 25, 2013 7:01 pm

Re: Broken Header Include Location

Post by Octocontrabass »

Where is the file you're putting the #include directive in?
User avatar
Octacone
Member
Member
Posts: 1138
Joined: Fri Aug 07, 2015 6:13 am

Re: Broken Header Include Location

Post by Octacone »

Octocontrabass wrote:Where is the file you're putting the #include directive in?
Oh... #-o :idea:
It is in a different directory... I can't use that since they are not starting from the same root point.

I figured this out: $OS -> exported path to my OS root folder.
Now how do I do this:

Code: Select all

#include "$OS/Headers/Kernel/Types.h"
OS: Basic OS
About: 32 Bit Monolithic Kernel Written in C++ and Assembly, Custom FAT 32 Bootloader
Octocontrabass
Member
Member
Posts: 5513
Joined: Mon Mar 25, 2013 7:01 pm

Re: Broken Header Include Location

Post by Octocontrabass »

You didn't answer my question. :roll:

To add to GCC's list of directories to search for headers, use "-iquote path" or "-I path". Paths added with "-iquote" will only be searched if you include with quotation marks, not angle brackets. (They're not really angle brackets.)
User avatar
Mikumiku747
Member
Member
Posts: 64
Joined: Thu Apr 16, 2015 7:37 am

Re: Broken Header Include Location

Post by Mikumiku747 »

It might be wise to look into the -I option of GCC, especially you'll have to change every single include statement if you decide to change the structure again.

Perhaps something like:

Code: Select all

i686-elf-gcc ... -I$OS/Headers ...
Would be good.

Never mind, Octocontrabass already made that suggestion
Octocontrabass
Member
Member
Posts: 5513
Joined: Mon Mar 25, 2013 7:01 pm

Re: Broken Header Include Location

Post by Octocontrabass »

Octocontrabass wrote:Where is the file you're putting the #include directive in?
Octocontrabass wrote:You didn't answer my question. :roll:
:roll:
User avatar
Octacone
Member
Member
Posts: 1138
Joined: Fri Aug 07, 2015 6:13 am

Re: Broken Header Include Location

Post by Octacone »

Mikumiku747 wrote:
It might be wise to look into the -I option of GCC, especially you'll have to change every single include statement if you decide to change the structure again.

Perhaps something like:

Code: Select all

i686-elf-gcc ... -I$OS/Headers ...
Would be good.

Never mind, Octocontrabass already made that suggestion
Thanks Octocontrabass and Mikumiku747 for helping me out. It works! =D>
OS: Basic OS
About: 32 Bit Monolithic Kernel Written in C++ and Assembly, Custom FAT 32 Bootloader
User avatar
Octacone
Member
Member
Posts: 1138
Joined: Fri Aug 07, 2015 6:13 am

[SOLVED] Broken Header Include Location

Post by Octacone »

Octocontrabass wrote:
Octocontrabass wrote:Where is the file you're putting the #include directive in?
Octocontrabass wrote:You didn't answer my question. :roll:
:roll:
It is in:
Sources/Kernel/Kernel.c
OS: Basic OS
About: 32 Bit Monolithic Kernel Written in C++ and Assembly, Custom FAT 32 Bootloader
Octocontrabass
Member
Member
Posts: 5513
Joined: Mon Mar 25, 2013 7:01 pm

Re: [SOLVED] Broken Header Include Location

Post by Octocontrabass »

octacone wrote:Sources/Kernel/Kernel.c
Wouldn't the correct include path be "../../Headers/Kernel/FileIwantToInclude.h"?
User avatar
Octacone
Member
Member
Posts: 1138
Joined: Fri Aug 07, 2015 6:13 am

[SOLVED] Broken Header Include Location

Post by Octacone »

Octocontrabass wrote:
octacone wrote:Sources/Kernel/Kernel.c
Wouldn't the correct include path be "../../Headers/Kernel/FileIwantToInclude.h"?
Oh you can do two of these: ../
Didn't know that :/
Thanks for helping!!
OS: Basic OS
About: 32 Bit Monolithic Kernel Written in C++ and Assembly, Custom FAT 32 Bootloader
Post Reply