START Adding new header files in subdirectory

Go To Last Post
3 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

So I'm having a bit of trouble with how the linker/Makefile are setup. Here is what I am doing:

 

  1. Download project from Atmel START (with GCC checked)
  2. If I enter the gcc folder I can build the base project just fine
  3. Create a folder called "user" in the project root and add "user_main.h" and "user_main.c" files
  4. In "main.c" in the root add "#include "user/user_main.h"
  5. Now when I compile I get "main.c:8: undefined reference to "user_main'" when I try to call a function defined in "user/user_main.h." It doesn't complain about not being able to find "user/user_main.h."

 

When I look in the provided Makefile, they seem to be listing all of the possible .o and .d files individually. I tried adding "user" to "SUB_DIRS" and "-I" ../user"" to "DIR_INCLUDES" but that didn't work. Am I seriously going to have to list each .o and .d file for each file I add? Why aren't they using wildcards at all? I also don't really want to modify the Makefile in case I need to update my START project.

 

What am I doing wrong?

 

Thanks!

Last Edited: Mon. Apr 26, 2021 - 06:50 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I did the same thing a couple of month ago, I just manually added the .o .d files. I created a makefile_begining.txt and listed all of my sourcefiles there, when I reconfigure the start project I just copy the contents of this file into the auto-generated makefile. Please note that I am a total noob when it comes to makefiles, but this got me started!

 

SUB_DIRS +=  \
\
user/subdir1 \
user/subdir2 \
 

OBJS +=  \
\
user/subdir1/source_a.o  \
user/subdir2/source_b.o  \

OBJS_AS_ARGS +=  \
\
"user/subdir1/source_a.o"  \
"user/subdir2/source_b.o"  \

 

DIR_INCLUDES +=  \
-I"../user" \
-I"../user/subdir1/" \
-I"../user/subdir1/" \

 

DEPS_AS_ARGS +=  \
\
"user/subdir1/source_a.d"  \
"user/subdir2/source_b.d"  \

 

 

 

if you figure out how to use wildcards in the autogenerated makefile then please let us know!

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hmmmm ok. That's what I figured but very unfortunate :(

 

I supposed I can make a script to do this automatically. Currently I have my own Makefile that sits in the root directory to handle OpenOCD, GDB, etc and it just changes to the gcc directory to compile. I can adjust it to modify the original Makefile as well I guess.