My confusion comes from phrases like "In a C environment" and "in a (MinGW-built) Perl environment".

An example:
Case 1 - what I (sloppily) meant by a "C environment":
gcc -o gmp.exe gmp.c -IC:/incs -LC:/libs -lgmp
Case 2 - what I (sloppily) meant by a "Perl environment"
perl Makefile.PL INC="-IC:/incs" LIBS="-LC:/libs -lgmp"
In the first case, I'm just building a test executable that needs the GMP library. It builds and runs fine.

In case 2, I'm trying to build Math::GMP - but that fails because "No library found for -lgmp". MakeMaker decrees that "-lgmp" means either "gmp.a" or "libgmp.a" - and in this particular instance, the import library that was built is named "libgmp.dll.a".

I had this half-baked idea that it would be nice if "-lgmp" worked the same in Case 2 as it did in Case 1 - and wondered if anyone had investigated the possibility. Hence my initial post in this thread. (MSVC compilers don't support the '-L' and '-l' conventions ... I probably should have omitted any consideration of those compilers.)

I've since been poking about a little, and I've just about decided that it's more trouble than it's worth. Far easier just to rename libgmp.dll.a to libgmp.a (and to do the same for other libraries, as necessary).

About the best that could be done to resolve the problem you are seeking to address, would be for the EU::MM to generate code in the makefile.pl it creates to cause it to go looking for each of the various suffixes when generating the makefile, and hardcode which ever it finds into the makefile

And wouldn't that be fun. I guess we could start by re-setting $Config{lib_ext} = ['.a', '.ddl.a', '.dll'] :-)
Though, as regards MinGW (but not MSVC), there should be no need to do any such hardcoding at all - unless it was decided to include '.lib' into the list of sought extensions, as I originally hinted. If '.lib' is not included then MakeMaker could just stick with the '-lfoo' stuff. There would be no need to convert to fully qualified file names, as is currently the case. And the libraries would be found at link time, irrespective of whether their names terminated with '.a', '.dll.a' or '.dll'.

Hmmm ... I wonder how much work that involves. I think that's the way it already works on nix systems, so it might not be as much work as one expects. That it would entail a major split with the way Makefiles are written for the MSVC compiler is less than enticing, but it's the thought of "what else gets broken" that's the major deterrent :-)

Cheers,
Rob

In reply to Re^2: [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.