Arduino Mk does not compile with sub folders.

Today I tried out the command line version of arduino.

I had succes with just a single ino file. I could compile, upload, use the monitor and clean the project.

I have an other project which has more source and header files, both next to the .ino as in the src sub directory. The arduino IDE itself does compile and upload the project without error.

The make file:

ARDUINO_DIR = /usr/share/arduino
ARDUINO_PORT = /dev/ttyUSB*

USER_LIB_PATH = /home/bask185/sketchbook/libraries
BOARD_TAG = nano328

include /usr/share/arduino/Arduino.mk

The last output of the compiler:

/tmp/ccbk3hRk.ltrans0.ltrans.o: In function `main':
<artificial>:(.text.startup+0xfc): undefined reference to `initIO()'
<artificial>:(.text.startup+0x100): undefined reference to `initTimers()'
<artificial>:(.text.startup+0x252): undefined reference to `leftShortCircuitT'
<artificial>:(.text.startup+0x260): undefined reference to `leftShortCircuitT'
<artificial>:(.text.startup+0x270): undefined reference to `rightShortCircuitT'
<artificial>:(.text.startup+0x2ce): undefined reference to `blinkT'
<artificial>:(.text.startup+0x2d6): undefined reference to `blinkT'
collect2: error: ld returned 1 exit status
/usr/share/arduino/Arduino.mk:1442: recipe for target 'build-nano328/amerikaBaan.elf' failed
make: *** [build-nano328/amerikaBaan.elf] Error 1

All the functions and variables with 'undefined reference' are all somewhere within the src subdirectory.

How is this fix-able? Must I add something to the Makefile?

Also side question, I am not going to use the library folder.. not ever. Is it safe to remove the line from the makefile?

Kin regards,

Bas

Sounds like a problem with the makefile. As someone who maintains a third party core, I get constant problems from people trying to use the makefile, which I am not an expert on. The makefiles making the rounds don't really seem to be fit for purpose yet, sad to say.

Everything gets made to work for the IDE - while the makefiles seem to be an approximation, and require constant updates and tweaks to make things work correctly, which work in the IDE without any complications. If they have a place at all, IMO, it is for very advanced users who understand how the makefile works, and are comfortable comparing the compilation steps between the official IDE (with verbose output) and building using makefile....

Why building with the makefile? Couldn't you use Arduino Builder from command line to build, and then sidestep all the issues relating to the makefile?