04-17-2015 07:02 AM
I am using Petalinux 2014.4. I try to include a header file out of my current directory. The following is the Makefile:
$(error "Error: PETALINUX environment variable not set. Change to the root of your PetaLinux install, and source the settings.sh file")
APP = dspclient
INC_DIR = ../../include/
CCFLAGS = -c -Wall -I$(INC_DIR))
DFPS = /include/ctrlreq.h
# Add any other object files to this list below
APP_OBJS = dspclient.o
APP_OBJS += process_mb_message.o
APP_OBJS += process_ps_message.o
APP_OBJS += process_analog_data.o
all: build install
$(CC) $(LDFLAGS) -o $@ $(APP_OBJS) $(LDLIBS)
-rm -f $(APP) *.elf *.gdb *.o
.PHONY: install image
$(TARGETINST) -d $(APP) /bin/$(APP)
$(CC) -c $(CFLAGS) -o $@ $<
This Makefile and all four source files are located in the current directory called dspclient. The dspclient.c contains a line that includes a head file (ctrlreq.h) outside of the current directory as below:
// in dspclient.c
The head file is located at two level above the current directory and then in a subdirectory called include. When I built the project using petalinux-build. I got the following error message.
fatal error: include/ctrlreq.h: no such file or directory
I have searched the forum, it seems I cannot find the information. I am very grateful if anybody can help me out.
04-19-2015 11:13 PM
Ensure that INC_DIR is added as a compiler search option.
NOTE: "myapp" is the name of sample application.
Edit : myapp/Makefile
$(CC) -I$(INC_DIR) -c $(CFLAGS) -o $@ $<
And include path is relative to build directory.
Hope it helps.
04-21-2015 07:17 AM
The problem solved after I manually copied the "include" directory from the " <pln_proj_roots>/component" directory to the "<pln_proj_roots>/build/linux/rootfs". Is there any way I can generate an "include" director in " <pln_proj_roots>/component" directory which includes all the common header files using petalinux-create and then this directory can be copied to the "<pln_proj_roots>/build/linux/rootfs" directory automatically when I run petalinux-build?