Forum Rule: Always post complete source code & details to reproduce any issue!
Results 1 to 4 of 4

Thread: includes search path for GCC Compiler?

  1. #1
    Senior Member
    Join Date
    Jul 2013
    Posts
    123

    Question includes search path for GCC Compiler?

    I am using make utility to compile blinky.c. The file specifies include files.
    Code:
    #include "usb_debug_only.h"
    #include "print.h"
    I have a copy of these include files in each directory containing a Makefile.
    It works, but there must a way to compile with just one copy in a search path, rather than a copy in each Makefile directory.
    Something like moving a copy of the include files into
    C:\WinAVR-20100110\lib\gcc\avr32\4.3.2\include\
    What's the best way to include "usb_debug_only.h" and "print.h" files for make and Teensy 2.0 on Windows 7?

    Thank you.

    Blinky source code: http://www.pjrc.com/teensy/blinky.zip
    The GCC Compiler and Tools Getting Started tutorial http://www.pjrc.com/teensy/gcc.html
    Last edited by wolfv; 09-08-2013 at 04:19 AM.

  2. #2
    Senior Member+ MichaelMeissner's Avatar
    Join Date
    Nov 2012
    Location
    Ayer Massachussetts
    Posts
    4,027
    Note, that #include "file.h" is meant to be a local file, and #include <file.h> is meant for global files.

    The options for the 4.3.x compiler shipped with the Arduino AVR IDE (and hence Teensy 2.0/2.0++) are at: http://gcc.gnu.org/onlinedocs/gcc-4....ectory-Options. Mostly the same options are for 4.7.x used for Teensy 3.0: http://gcc.gnu.org/onlinedocs/gcc-4....ectory-Options

    In addition there are environment variables that the compiler uses: http://gcc.gnu.org/onlinedocs/gcc-4....ment-Variables and http://gcc.gnu.org/onlinedocs/gcc-4....ment-Variables.
    Last edited by MichaelMeissner; 09-08-2013 at 05:44 AM.

  3. #3
    Senior Member
    Join Date
    Aug 2013
    Location
    Gothenburg, Sweden
    Posts
    412
    You must add an include path directory specification to the the command line sent to the compiler.
    The syntax is : -I {Path to directory containing include files}
    Optional extras to the compiler are usually in a variable called CFLAGS or similar, you add simething like

    CFLAGS = ..... /* heres a lot of other stuff */.... -I /home/nicke/arbete/arduino-1.0.5/hardware/teensy/cores

  4. #4
    Senior Member
    Join Date
    Jul 2013
    Posts
    123
    Thanks Micheal and mlu. The blinky Makefile from http://www.pjrc.com/teensy/blinky.zip comes with macro's that insert -I, it worked well.

    Here are the lines from the blinky Makefile
    Code:
    # List any extra include directories here.
    EXTRAINCDIRS =
    
    ...
    
    CPPFLAGS += $(patsubst %,-I%,$(EXTRAINCDIRS))

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •