GNU linkers (both default ld and gold) requires specific order of its inputs: gcc -o m -Inimcache main.c libnim.a Run
main.c has a dependency on symbols from libnim.a thus it needs to come before libnim.a in a linking invocation. In your case the linker sees only unused symbols from libnim.a and tosses it out. Only then it reads contents from main.c, sees symbols it can't resolve (libnim.a is now out of the picture) and gives you linker errors.