How to include external header file

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
WGT_4383351
Level 5
Level 5
First like received

Two Eclipse FX3 projects need some common external header file. The file have been included in to the project by creating a Linked Folder in Eclipse, the header file appear in the project tree, but during build the header can't be found.

I include such line into makefile in the project:

Include += -I"absolute path to the external folder that contains the header"

after

include $(FX3FWROOT)/common/fx3_build_config.mak

But it doesn't work. And even the line

include $(FX3FWROOT)/common/fx3_build_config.mak

is removed, during build the arm-none-eabi-gcc command line still use the same -I as before - the updated makefile doesn't have effect at all.

0 Likes
1 Solution
Hemanth
Moderator
Moderator
Moderator
First like given First question asked 750 replies posted

Hi,

You can directly add the header file into the project folder in your Workspace - change of make file is not needed (they are autogenerated - and will be changed on every build). Other option is to add the header file directory in the following place:

pastedImage_0.png

Regards,

Hemanth

Hemanth

View solution in original post

3 Replies
Hemanth
Moderator
Moderator
Moderator
First like given First question asked 750 replies posted

Hi,

You can directly add the header file into the project folder in your Workspace - change of make file is not needed (they are autogenerated - and will be changed on every build). Other option is to add the header file directory in the following place:

pastedImage_0.png

Regards,

Hemanth

Hemanth
WGT_4383351
Level 5
Level 5
First like received

Other option is to add the header file directory in the following place” this works, but the makefile under the project root is not regenerated to include that path even after build, not sure where does that added folder come from during build.

0 Likes
Hemanth
Moderator
Moderator
Moderator
First like given First question asked 750 replies posted

Make file gets updated when new source file (.c) is added. For the first option - you can add the header file in the project folder and do #include "x.h" in the .c file. This should work.

Regards,

Hemanth

Hemanth
0 Likes