K
K
Kamikaze10242017-02-02 14:38:23
linux
Kamikaze1024, 2017-02-02 14:38:23

How to add include path to gcc system paths?

Good afternoon! I want to add boost directories to gcc system paths via makefile. How to do it?

PROJECT   = fiscat
CC        = arm-linux-gcc
CXX       = arm-linux-g++
STRIP     = arm-linux-strip

ifeq ($(DEBUG), 1)
FLAGS     = -O0 -ggdb3 -DDEBUG
else
FLAGS     = -O2 -DNDEBUG
endif
FLAGS    += -Werror

OFLAGS    = $(FLAGS)
OFLAGS   += -Isrc/appl/include -Isrc/bsp/include
OFLAGS   += -D__FILENAME__='"$(notdir $<)"'

CFLAGS    = $(OFLAGS) -Isrc/readyBoost/include/boost -std=gnu99
CXXFLAGS  = $(OFLAGS) -Isrc/readyBoost/include/boost -std=c++11 -Wall

TARGET    = bin/fiscat
CSRC      = $(shell find src -name *.c)
CXXSRC    = $(shell find src -name *.cpp)
COBJ      = $(patsubst %.c,   %.o, $(CSRC))
CXXOBJ    = $(patsubst %.cpp, %.o, $(CXXSRC))
LDLIBS    = -lpthread -lsrc/readyBoost/lib

all: $(TARGET)

$(TARGET): $(COBJ) $(CXXOBJ)
  rm -rf bin; mkdir bin/
  $(CXX) $(FLAGS) $(COBJ) $(CXXOBJ) $(LDLIBS) [email protected]
ifneq ($(DEBUG), 1)
  $(STRIP) $(TARGET)
endif
  @du -h $(TARGET)
  @file $(TARGET)

%.o: %.c
  $(CC) $(CFLAGS) -c $< -o [email protected]

%.o: %.cpp
  $(CXX) $(CXXFLAGS) -c $< -o [email protected]

clean:
  find src -name *.o -delete
  rm -fr $(TARGET)

Answer the question

In order to leave comments, you need to log in

1 answer(s)
C
CityCat4, 2017-02-02
@Kamikaze1024

No way. System paths are hardcoded. They can only be changed by rebuilding gcc itself. Makefile for this and serves to prescribe all the necessary paths and so on. And that is why so many different things were screwed on top of it - pkgconfig, autotools, cmake - they all seem to be designed to facilitate the work of a programmer in building a project, but in fact they can easily confuse him into the trash, especially cmake :)
If you are thinking about project portability - then you either have to deal with autotools (although you will have to deal with them anyway), or with cmake.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question