Are you saying that with your case 1 command line: gcc -o gmp.exe gmp.c -IC:/incs -LC:/libs -lgmp, the compiler or the linker does some kind of search and manages to resolve -lgmp to libgmp.dll.a?

Yep - that's effectively what happens. If it first finds a libgmp.a then it would use that ... and if libgmp.a, gmp.dll.a, libgmp.dll.a were all unlocatable it would look for (and then use) either libgmp.dll or gmp.dll.

Or does the gcc linker know how to resolve entrypoints directly against a .dll/.so?

Yes, it can do that. (Though assigning a '.so' extension would break all conventions.)

It's probably a moot point, but I believe that (strictly speaking) only 2 file extensions are recognised - namely '.a' and '.dll'. The '.dll' in '.dll.a' is really part of the filename - certainly one can rename libfoo.dll.a to libfoo.a (and vice-versa) without introducing any problems. It looks like the convention is that '.dll.a' is an import lib (for a dynamic build) whereas '.a' is for a static library. But gcc doesn't need to know whether it's dealing with an "import lib" or a "static lib". Presumably the distinction is being made so that the programmer can instantly recognise whether it's a static or dynamic build. Otoh, if you want to link directly to libfoo.dll then gcc apparently does need to know that it's dealing with a dll. If you rename the dynamic library libfoo.dll to libfoo.a and link to it by specifying "-lfoo" on the command line, then linking will fail.

Strikes me if gcc can resolve a -lxxx switch to all those different file names, having MM generate full names for them on win32 just makes extra unnecessary work.

Agreed - and undoing that work is what I'm thinking about. I imagine that "extra unnecessary work" is simply there for the benefit of the Microsoft Compilers (which *do* need it), and that it was deemed easier to just lump MinGW and MSVC together where possible. That is, I think it quite likely that there are historical/evolutionary reasons that things are the way they are.

But every time I've looked to work out how to get the resultant hacked makefile, to be generated that way in the first place, I've ended up getting entirely lost and frustrated with the whole object-oriented, 'executable configuration files' that is EU::MM (and Module::Build).

It's heartening to hear that .... I had always assumed it was "just me" :-)

Cheers,
Rob

In reply to Re^4: [Win32] The '-l' switch, and for which files the linker looks. by syphilis
in thread [Win32] The '-l' switch, and for which files the linker looks. by syphilis

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.