allonymist ([info]allonymist) wrote,
@ 2007-04-30 23:42:00
Previous Entry  Add to memories!  Tell a Friend!  Next Entry
Entry tags:coding, frustration, mingw

commit message of the day.

For reasons which make sense to somebody, I'm sure, mingw gcc wants the libraries to appear at the end of the command line.  This is done by specifying them with LDADD in Makefile.am, not LDFLAGS.

If anybody can explain to me why mingw thinks "gcc -o foo foo.o -lbar" is fine, whereas "gcc -lbar -o foo foo.o" is Doubleplusbad UnMingwThink, I'd quite appreciate it.  Until then, 'll just do what seems to work, and hope we don't blunder across any other great slumbering cthonian deities of arbitrary syntax.


Man. I should re-do that in the form of Xanadu or something:

In min-g-win did automake a messy linker line decree
Where "-l" the romping option ran
Through lines that seemed unchanged to man
   Down to a sundered C.
So twice five hours of wasted time
With a-c-include were frittered down...


(Post a new comment)


[info]yoctohedron
2007-05-04 04:17 pm UTC (link)
Actually, that's a pretty common constraint.. I'm surprised that other gccs are cleverer. At least back when I did C, the linker was single-pass. Something like:
resolved_symbols = {}
unresolved_symbols = []
for file in files:
    if file.endswith(".o"):
        resolve_what_you_can(file, resolved_symbols)
        resolved_symbols.update(extract_resolved_symbols(file))
        unresolved_symbols.extend(extract_unresolved_symbols(file))
        unresolved_symbols.remove_many(resolved_symbols.keys())
    if file.endswith(".a"):
        for f2 in extract_components(file):
            # same as for a single .o
if unresolved_symbols:
    raise UnresolvedSymbolError
So you had to mentally figure out the dependency graph (for both the .o and the .a) and arrange them in that order. Usually that meant all your .o first, then any .a that you've written yourself, then all the system .a, ending in -lc and the implicit -lgcc. There was an option to put a set of brackets around the .o/.a list, and loop over that set until no more progress could be made. Maybe compilers do that by default these days.

(Reply to this)


Create an Account
Forgot your login?
Login w/ OpenID
English • Español • Deutsch • Русский…