tags:

views:

76

answers:

2

Any idea about this error?

gcc   -oxtmpmain.exe xtmpmain.o fiber_driver.o xtmp_options.o getopt.o D:\usr\xtensa\XtDevToolsDE\in
stall\tools\RB-2008.4-win32\XtensaTools\lib\iss\xtmp.lib
xtmpmain.o(.text+0x213):xtmpmain.c: undefined reference to `_uart_setup'
xtmpmain.o(.text+0x2da):xtmpmain.c: undefined reference to `_uart_cleanup'
collect2: ld returned 1 exit status
make: *** [xtmpmain.exe] Error 1
+4  A: 

This is a plain linking error. You're calling two functions, uart_setup() and uart_cleanup(), that the linker is not finding.

There might be several causes, including (but certainly not limited to):

  • They really are missing, perhaps you forgot to link against one object file
  • Namespacing preventing the existing function from being found
  • Library paths
  • Marshalling or problems with external names and underscores

Without more detail, it's hard to tell for sure.

unwind
+1  A: 

It means that xtmpmain.c called functions named uart_setup() and uart_cleanup(), but they weren't found by the linker. You probably need to include a library, or to implement those functions for Windows in terms of the Win32 API.

Some "is it plugged in questions" are:

  • Are the functions declared?
  • Are the functions defined (i.e. implemented)?
  • With exactly those names?
  • Were those definitions excluded by the preprocessor?
  • There is a gcc option that controls the presence or absence of a leading underscore. You didn't accidentally use that for one file and not others, right?
  • Verify the declared calling convention. __cdecl and __stdcall are very different animals. They usually produce mismatched exported symbol names for safety, and this error can be a symptom of that.

If this is a porting project, then it is likely that the original implementation of a UART-related function is written in a platform-dependent way. In that case, they often would be guarded by a #ifdef of some form that depends on the compile-time platform.

To resolve that, you would need to implement them for this platform, in a style consistent with their usage in the rest of the application, and similarly guarded.

RBerteig
how? These two fns are defined by me in xtmpmain.cits similar to ordinary fns r8?
Renjith G
They weren't defined with those exact names (without the leading underscore which is common C name mangling) in any file named on your link line, or the linker would have found them. Check the spelling carefully, and make sure that they weren't skipped over by #ifdef or the like.
RBerteig