Getting undefined ref error, suspecting Makefile [solved]

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

Hi everyone,

I have attached a zip folder of my project (it's a simple one).

I have a main.c file, which is attempting to read data from a temperature sensor, and output it via the USART. The USART works great and all, but today I tried hooking up the sensor (DHT-11) which I tested with an Arduino. My MCU is the ATMega8. So I downloaded the library files for my MCU to interface with the sensor. It came with DHT.c and DHT.h.

I have included in the zip folder the makefile (which I suspect to be the problem), DHT.h, DHT.c, and main.c.

The problem I am getting is when I run the makefile, I get:

main.c:22: undefined reference to `DHT_Read_Data'
make: *** [main.elf] Error 1

I would really appreciate your time and help! Please let me know if more info is required. Many thanks.

Attachment(s): 

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

You have not added the DHT.c source file to the list of files to be compiled.

You need to adjust your makefile to this:

# List C source files here. (C dependencies are automatically generated.)
SRC = $(TARGET).c DHT.c

Since the base of your makefile is the MFile utility's template makefile, you could well use MFile to do the editing of your makefile. Might be safer if you are new to the syntax, format and semantics of makefiles.

As of January 15, 2018, Site fix-up work has begun! Now do your part and report any bugs or deficiencies here

No guarantees, but if we don't report problems they won't get much of  a chance to be fixed! Details/discussions at link given just above.

 

"Some questions have no answers."[C Baird] "There comes a point where the spoon-feeding has to stop and the independent thinking has to start." [C Lawson] "There are always ways to disagree, without being disagreeable."[E Weddington] "Words represent concepts. Use the wrong words, communicate the wrong concept." [J Morin] "Persistence only goes so far if you set yourself up for failure." [Kartman]

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

Thanks a bunch!

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

You're welcome! :D

As of January 15, 2018, Site fix-up work has begun! Now do your part and report any bugs or deficiencies here

No guarantees, but if we don't report problems they won't get much of  a chance to be fixed! Details/discussions at link given just above.

 

"Some questions have no answers."[C Baird] "There comes a point where the spoon-feeding has to stop and the independent thinking has to start." [C Lawson] "There are always ways to disagree, without being disagreeable."[E Weddington] "Words represent concepts. Use the wrong words, communicate the wrong concept." [J Morin] "Persistence only goes so far if you set yourself up for failure." [Kartman]