User forums > Using Code::Blocks

Use directory relative to source file directory in Search Directory

(1/1)

J-No:
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

BlueHazzard:
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

--- End code ---
you can simply write

--- Code: ---#include "../includes/a.h"
--- End code ---

Navigation

[0] Message Index

Go to full version