Author Topic: Use directory relative to source file directory in Search Directory  (Read 4108 times)

J-No

  • Guest
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

Offline BlueHazzard

  • Developer
  • Lives here!
  • *****
  • Posts: 3353
Re: Use directory relative to source file directory in Search Directory
« Reply #1 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"