Programming, for all ages and all languages.
Octacone
Member
Posts: 1138 Joined: Fri Aug 07, 2015 6:13 am
Post
by Octacone » Wed Sep 28, 2016 6:52 am
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
Octacone
Member
Posts: 1138 Joined: Fri Aug 07, 2015 6:13 am
Post
by Octacone » Wed Sep 28, 2016 7:08 am
Octocontrabass wrote: Where is the file you're putting the #include directive in?
Oh...
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
Posts: 5513 Joined: Mon Mar 25, 2013 7:01 pm
Post
by Octocontrabass » Wed Sep 28, 2016 7:17 am
You didn't answer my question.
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.)
Mikumiku747
Member
Posts: 64 Joined: Thu Apr 16, 2015 7:37 am
Post
by Mikumiku747 » Wed Sep 28, 2016 7:20 am
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
Posts: 5513 Joined: Mon Mar 25, 2013 7:01 pm
Post
by Octocontrabass » Wed Sep 28, 2016 7:34 am
Octocontrabass wrote: Where is the file you're putting the #include directive in?
Octocontrabass wrote: You didn't answer my question.
Octacone
Member
Posts: 1138 Joined: Fri Aug 07, 2015 6:13 am
Post
by Octacone » Wed Sep 28, 2016 7:34 am
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!
OS: Basic OS
About: 32 Bit Monolithic Kernel Written in C++ and Assembly, Custom FAT 32 Bootloader
Octacone
Member
Posts: 1138 Joined: Fri Aug 07, 2015 6:13 am
Post
by Octacone » Wed Sep 28, 2016 7:36 am
Octocontrabass wrote: Octocontrabass wrote: Where is the file you're putting the #include directive in?
Octocontrabass wrote: You didn't answer my question.
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
Posts: 5513 Joined: Mon Mar 25, 2013 7:01 pm
Post
by Octocontrabass » Wed Sep 28, 2016 11:40 am
octacone wrote: Sources/Kernel/Kernel.c
Wouldn't the correct include path be "../../Headers/Kernel/FileIwantToInclude.h"?
Octacone
Member
Posts: 1138 Joined: Fri Aug 07, 2015 6:13 am
Post
by Octacone » Thu Sep 29, 2016 12:35 pm
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