Atilla Filiz
Atilla Filiz

Reputation: 2432

How do I work around gnu linker command line pickiness?

This question and its answer explains the importance of linking command line order.

However, I deal with a lot of makefiles containing lines like

$(CC) $(LDFLAGS) $^ -o $@

Aparently, commands like these just work on some systems, but not on mine. Is there a way to work around this behaviour other than finding and patching all Makefiles like these?

I am using gcc (Ubuntu/Linaro 4.6.3-1ubuntu5) 4.6.3

EDIT for clarification:
I do a lot of patching and integration as part of my job(Usually buildroot or LTIB) , and I come across multiple makefiles written like this. Also some example compiling commands on the web follow the same pattern.

Upvotes: 0

Views: 90

Answers (1)

ams
ams

Reputation: 25599

So, the problem is that some idiot has created a makefile that puts all the library options before the .o file. Presumably there is some broken toolchain out there that doesn't care, but that doesn't help you.

There's only two options here:

  1. Fix the makefile.
  2. Create a compiler wrapper that reorders the options. Such a wrapper would be broken in general, but could make it work for the exact pattern used by your makefiles.

I did wonder if --start-group would help you here, but a quick experiment suggests not.

Upvotes: 1

Related Questions