Code::Blocks Forums

User forums => Using Code::Blocks => Topic started by: J-No on August 26, 2021, 05:02:48 pm

Title: Use directory relative to source file directory in Search Directory
Post by: J-No on August 26, 2021, 05:02:48 pm
Hello everyone,

I have a codeblocks project with severals sources directories, like this structure:

<Project dir>\Dir 1\Dir 1.1\sources
                                        \includes
                             Dir 1.2\sources
                                        \includes

When I compile src files from one sources directory, I want to add dedicated includes dir in search dir.

I try to use in Search directories project $(file_dir)..\includes, but when I compile $(file_dir) is empty (not visible).
I know it is possible to add in -I$(file_dir)..\includes in Command line macro, but I want to use this feature only with my Workspace /Project.

How to do that ?

Thak you for your help
Title: Re: Use directory relative to source file directory in Search Directory
Post by: BlueHazzard on August 27, 2021, 11:15:41 pm
I am not 100% sure what you are asking for, but you can add include directories in Project->Build options->Search directories->Compiler
this paths are relative to the project path


You can always work relative to your source file,
if you want to include a.h in a.cpp
Code
Dir1\Dir1.1\sources\a.cpp
                 \includes\a.h
you can simply write
Code
#include "../includes/a.h"