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

Thread: Compiling C - Makefile problems (Teensy 3.0)

  1. #1
    Junior Member
    Join Date
    Aug 2013
    Posts
    3

    Unhappy Compiling C - Makefile problems (Teensy 3.0)

    I'm sort of astonished that every post out there concerning C compilation for the Teensy 3.0 says some variation on, "Just look at the makefile comments." Well I did, and this is what I think should work (last half of the makefile remains unaltered):

    Code:
    # The name of your project (used to name the compiled .hex file)
    TARGET = main
    
    # configurable options
    OPTIONS = -DF_CPU=48000000 -DUSB_SERIAL -DLAYOUT_US_ENGLISH
    
    # options needed by many Arduino libraries to configure for Teensy 3.0
    OPTIONS += -D__MK20DX128__ -DARDUIO=104
    
    
    #************************************************************************
    # Location of Teensyduino utilities, Toolchain, and Arduino Libraries.
    # To use this makefile without Arduino, copy the resources from these
    # locations and edit the pathnames.  The rest of Arduino is not needed.
    #************************************************************************
    
    # path location for Teensy Loader, teensy_post_compile and teensy_reboot
    #TOOLSPATH = ../../../tools   # on Linux
    TOOLSPATH = E:\Program Files (x86)\Arduino\hardware\tools\avr\bin
    
    # path location for Arduino libraries (currently not used)
    #LIBRARYPATH = ../../../../libraries
    
    # path location for the arm-none-eabi compiler
    COMPILERPATH = E:\Program Files (x86)\Arduino\hardware\tools\arm-none-eabi\bin
    In the standard installation of Teensyduino, in the /hardware/teensy/cores/teensy3/ directory, I run "make" (which points to /hardware/tools/arm-none-eabi/bin/ from my PATH variable). Here's where the weirdness starts.

    Upon first run, I get this: http://pastebin.com/aWFmpJDR
    There's an error at the end, but the hex file gets created correctly, I upload it with the teensy loader, and my teensy 3.0 starts blinking correctly. Great.

    I can then go in and delete all the .o, .d, and the elf and hex files (essentially what 'make clean' does right?) and run 'make' again. This time, I get:
    Code:
    E:\Program Files (x86)\Arduino\hardware\teensy\cores\teensy3>make
    E:/Program Files (x86)/Arduino/hardware/teensy/cores/teensy3/E:\Program E:/Program Files (x86)/Arduino/hardware/teensy/cores/teensy3/Files E:/Program Files (x86)/Arduino/hardware/teensy/cores/teensy3/
    (x86)\Arduino\hardware\tools\arm-none-eabi\bin/arm-none-eabi-gcc  -Wall -g -Os -mcpu=cortex-m4 -mthumb -nostdlib -MMD -DF_CPU=48000000 -DUSB_SERIAL -DLAYOUT_US_ENGLISH -D__MK20DX128__ -DARDUIO=104 -I.
      -c -o analog.o analog.c
    process_begin: CreateProcess(NULL, E:/Program Files (x86)/Arduino/hardware/teensy/cores/teensy3/E:\Program E:/Program Files (x86)/Arduino/hardware/teensy/cores/teensy3/Files E:/Program Files (x86)/Ard
    uino/hardware/teensy/cores/teensy3/(x86)\Arduino\hardware\tools\arm-none-eabi\bin/arm-none-eabi-gcc -Wall -g -Os -mcpu=cortex-m4 -mthumb -nostdlib -MMD -DF_CPU=48000000 -DUSB_SERIAL -DLAYOUT_US_ENGLIS
    H -D__MK20DX128__ -DARDUIO=104 -I. -c -o analog.o analog.c, ...) failed.
    make (e=2): The system cannot find the file specified.
    make: *** [analog.o] Error 2
    After that, it doesn't matter what main.cpp contains, I will get this error.

    Besides this method of compiling, the closest I've come is using the Coocox CoIDE. When I Build, the console always ends with "BUILD SUCCESSFUL" but my hex files are essentially empty (two lines), no matter the code in my main.c.

    I don't mind any method of compilation if it works. I've been through tutorials for setting up CoIDE, Eclipse w/ some plugins, Visual Studio, etc, etc and have not been able to cross the finish line.

    ANY and ALL insight into my issue(s) would be appreciated!!!

  2. #2
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    20,326
    TL;DR: check "TOOLSPATH" within your makefile. It's probably wrong.

    Look at this line from the bad output:

    Code:
    E:/Program Files (x86)/Arduino/hardware/teensy/cores/teensy3/E:\Program E:/Program Files (x86)/Arduino/hardware/teensy/cores/teensy3/Files E:/Program Files (x86)/Arduino/hardware/teensy/cores/teensy3/(x86)\Arduino\hardware\tools\arm-none-eabi\bin/arm-none-eabi-gcc  -Wall -g -Os -mcpu=cortex-m4 -mthumb -nostdlib -MMD -DF_CPU=48000000 -DUSB_SERIAL -DLAYOUT_US_ENGLISH -D__MK20DX128__ -DARDUIO=104 -I. -c -o analog.o analog.c
    Here's the same line from the good output you put on pastebin:

    Code:
    E:/Program Files (x86)/Arduino/hardware/tools/arm-none-eabi/bin/arm-none-eabi-gcc  -Wall -g -Os -mcpu=cortex-m4 -mthumb -nostdlib -MMD -DF_CPU=48000000 -DUSB_SERIAL -DLAYOUT_US_ENGLISH -D__MK20DX128__ -DARDUIO=104 -I. -c -o analog.o analog.c
    They are exactly the same, except the bad one has the full pathname to the compiler program concatenated 3 times. The error "make (e=2): The system cannot find the file specified." means make could not run the compiler. This is NOT an error from the compiler that it can't find a file like analog.c.

    Make can't find "arm-none-eabi-gcc" which is in "E:/Program Files (x86)/Arduino/hardware/tools/arm-none-eabi/bin/" because somehow the pathname got really messed up.

    How merely deleting the .o and .d files could do that, I have no idea.

    Maybe something else was changed, perhaps with the TOOLSPATH definition within the makefile?

  3. #3
    Junior Member
    Join Date
    Aug 2013
    Posts
    3
    Hi Paul, thanks for the quick reply!

    [edit] OH, there's some problems with the "Program Files (x86)" folder name. Time to put this whole installation somewhere lower w/o spaces in directory name.

    Is there something wrong with using absolute paths in the makefile? Is the gcc arm make picky about slash direction (forward/back)?

    The absolute path as written is correct. It looks like the concatenation of absolute paths (that you quoted from my failed compilation attempt) stems from part of the makefile that says:
    Code:
    CC = $(abspath $(COMPILERPATH))/arm-none-eabi-gcc
    ...etc...
    As far as I can understand it, 'abspath' has the first chunk, my current working directory. 'COMPILERPATH' has the second chunk, as defined earlier in the makefile. I don't understand where the third chunk comes from.

    Since I have the arm-none-eabi-gcc tools path in my windows7 PATH variable, can i just remove the references to 'abspath' and 'COMPILERPATH' completely?

  4. #4
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    20,326
    This worked before, right? You posted the correct output it had during the first run. I'd try to get back to that...

    Maybe try extracting a fresh copy of Arduino (using the zip file, not the Arduino's installer, extracted to a new location), install Teensyduino to that new location, then run that makefile?

  5. #5
    Junior Member
    Join Date
    Aug 2013
    Posts
    3
    OK i've got it all worked out, at least to the point that I can compile valid hex files with a main() inside some file in the /hardware/teensy/cores/teensy3 directory. All the IDE's i've been trying are complaining about not being able to find things (even though they're clearly #include'd), but I suppose that's their (my) problem, and not yours!

    Thanks,
    D

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
  •