Linker error: undefined reference to `_fini'

2019-06-06 02:16发布

问题:

I am just getting strted with lpcXpresso for embedded system development. It uses a modifed Eclise as its IDE and an MCU C compiler and MCU linker.

I imported some eisting code and had a few linker errors, which I soon sorted out. But the final one has me stumped:

undefined reference to `_fini'  

I would expect that that means that some of my code calls a function called fini() - right?

Except that I don't have one (admiteddly there is an InitialzeTracingSubsystem()). And I don't believe that the linker is truncating the name because it earlier complained of _getimeofday.

Any idea what I am doing wrong?

回答1:

You didn't show your command line. I am guessing you've used ld (the linker) directly.

Don't do that. Instead, always use the compiler driver to do the linking.

The _init and _fini are usually part of libc, or the C runtime startup files (crt0.o, crtend.o, etc.) that come with it.

The compiler driver will do the magic necessary to link them in. The linker would not.



标签: linker