0

Currently I am trying to compile binaries for the AT91SAM7S256 using SEGGER, and I've been running into an issue at the linking phase (source files all compile fine) where any file that makes use of "lib_AT91SAM7S64.h" has multiple undefined references when attempting to link.

Here's a sample of some of the error messages:

Output/Executable_1 Debug/Obj/AdcInterface.o: In function `initializeADCInterface':
undefined reference to `AT91F_PIO_CfgInput'
undefined reference to `AT91F_PIO_InterruptEnable'
undefined reference to `AT91F_PIO_GetInterruptStatus'

The thing is that these functions that're "undefined" are defined within the "lib_AT91SAM7S64.h" file. I'm at a loss as to what to do, as I've never ran into errors during the linking phase before.

I am not using any makefiles or anything. This project was originally developed using Green Hills Software, but it compiles and builds without issue on that IDE. I do not have access to Green Hills Software, however, and have been trying to get SEGGER to compile this.

Russ Schultz
  • 2,545
  • 20
  • 22
C. Parks
  • 63
  • 6
  • 1
    The functions might be _declared_ in the .h file but they're not _defined_ in the .h file. How are you specifying the library file in the project properties or on the command line? – kkrambo Apr 11 '16 at 16:01
  • 1
    Are they really _defined_ in the header - i.e. a static inline implementation - or just _declared_, because without further details it just looks like your typical "forgetting to pass an external library to the linker" or "linking interdependent objects in the wrong order" issue, which are exactly the kind of things which might differ between different IDE-generated build commands. – Notlikethat Apr 11 '16 at 16:01
  • Thank you, Notlikethat. As it turns out, there was some declaration issues in the header file. "__inline" was being used, so I added a define at the top of the file "#define __inline static inline" and the issues related to the undefined functions that do exist went away. – C. Parks Apr 11 '16 at 16:24
  • 1
    Possible duplicate of [What is an undefined reference/unresolved external symbol error and how do I fix it?](http://stackoverflow.com/questions/12573816/what-is-an-undefined-reference-unresolved-external-symbol-error-and-how-do-i-fix) – Paul R Apr 11 '16 at 16:38

1 Answers1

3

Almost certainly you're not linking in the library that has the actual code to these functions. The .h only defines them so that other code can correctly call these functions.

You must (somehow) specify the .a that includes these symbols. I'm not sure if that means you need to edit your makefile, or add some .a to the project, or specify in the IDE what hardware you're building to. Sorry, I don't use SEGGER, so I don't know those details. Hopefully this is enough to move your forward to find your solution.

Russ Schultz
  • 2,545
  • 20
  • 22