PB[C] - Include path for C headers

Just starting out? Need help? Post your questions and find answers here.
User avatar
the.weavster
Addict
Addict
Posts: 1537
Joined: Thu Jul 03, 2003 6:53 pm
Location: England

PB[C] - Include path for C headers

Post by the.weavster »

How do I pass a C headers include path from the PB IDE to the gcc compiler?
Somehow I need to end up with:

Code: Select all

gcc ... -IC:\path\to\headers
Just using the absolute path for the include:

Code: Select all

!#include <C:\path\to\headers\header1.h>
doesn't work because header1.h may include header2.h etc...
User avatar
idle
Always Here
Always Here
Posts: 5094
Joined: Fri Sep 21, 2007 5:52 am
Location: New Zealand

Re: PB[C] - Include path for C headers

Post by idle »

You shouldn't be using #include </path> for your files that's for system files, like #include <stdio.h>

To import portaudio for instance I did this

Code: Select all

ImportC "-lportaudio" : EndImport     ;tel the linker to include the lib 
!#include "/usr/include/portaudio.h"  ;tell c where the header is 
User avatar
the.weavster
Addict
Addict
Posts: 1537
Joined: Thu Jul 03, 2003 6:53 pm
Location: England

Re: PB[C] - Include path for C headers

Post by the.weavster »

idle wrote: Thu Jan 06, 2022 8:57 pm You shouldn't be using #include </path> for your files that's for system files, like #include <stdio.h>
Thanks.
idle wrote: Thu Jan 06, 2022 8:57 pm To import portaudio for instance I did this

Code: Select all

ImportC "-lportaudio" : EndImport     ;tel the linker to include the lib 
!#include "/usr/include/portaudio.h"  ;tell c where the header is 
The problem I was having (Windows) was that if I tried to import a header using an absolute path and that header imported another using a relative path compilation would fail.

After a bit of Googling I found I can set an environment variable, C_INCLUDE_PATH, containing a list of folders for gcc to search in.

I'm edging forward slowly :)

* Edit *
I have another install of gcc from MSYS64 and that seems happy with the C_INCLUDE_PATH variable, I can use Geany to build from C files, but PB's gcc still reports file not found errors :(
User avatar
idle
Always Here
Always Here
Posts: 5094
Joined: Fri Sep 21, 2007 5:52 am
Location: New Zealand

Re: PB[C] - Include path for C headers

Post by idle »

You might be able to set additional paths through gcc options in importc also. Hope you work it out
Post Reply