Renjith G
Renjith G

Reputation: 6727

Help with error message from gcc

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

Upvotes: 1

Views: 205

Answers (2)

RBerteig
RBerteig

Reputation: 43356

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.

Upvotes: 1

unwind
unwind

Reputation: 400039

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.

Upvotes: 4

Related Questions