| Why do I get "Undefined Reference to..." errors?

Previous | The C Language | Next

Q:

When I tried to compile my program, the linker reports to me

    Undefined reference to ...

although my program seems correct. What's a problem?

A:

In earlier releases of TIGCC (before 0.9) this usually meant that you need to include some patches in your program. As TIGCC now does it automatically, if you still have an undefined reference error, that either something is wrong with your program (more probably you used a function which is not defined elsewhere, maybe due to typing error), or you used something which is not implemented yet in TIGCC (which is probably true if you got an undefined reference to a symbol which begins which the double underscore `'__'`). For example, although TIGCC supports very long (64-bit) integers (`'long long'` type, which is a GNU C extension), the support for multiplying and dividing double longs is not supported yet. For example, if you try to divide two double-long numbers, you will get an undefined reference to `'__udivdi3'`. Sorry, there is no simple help for this. You must live without 64-bit division for now. It will be implemented in the future.