Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

EU::MM again.

by BrowserUk (Pope)
on Mar 25, 2009 at 07:12 UTC ( #753039=perlquestion: print w/ replies, xml ) Need Help??
BrowserUk has asked for the wisdom of the Perl Monks concerning the following question:

I've been trying to install DBD::Pg on a 64-bit AS Perl.

Using the makefile.pl generated makefile, the compile works, but the link step fails because it is trying to use the 32-bit libpq.lib.

I've built 64-bit versions of these and succeeded in linking against them manually to produce a DBD::Pg that works, but I cannot work out how to modify the makefile.pl to incorporate the changes.

Essentially all that needs to be done is to change the link step reference from libpq.lib to libpq64.lib, but I'll be damned if I can work out how the makefile.pl picks up/generates the references to libpq.lib.

Can anyone offer pointers?

For a full patch, it would also be necessary to make the generated reference--libpq.lib vs. libpq64.lib--dependant upon the flavour of Perl it is being generated for. Clues how to go about that also appreciated.


Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.

Comment on EU::MM again.
Re: EU::MM again.
by grinder (Bishop) on Mar 25, 2009 at 07:50 UTC
    Can anyone offer pointers?

    I may be being thick (it wouldn't be the first time) and thus be missing a subtle point to your question, but what you want to do is quite simple:

    my @lib_flags = qw(this that other); if (running_on_64bit()) { push @lib_flags, 'libpq64.lib'; } else { push @lib_flags, 'libpq.lib'; } # ... time passes WriteMakefile( NAME => 'DBD::Pg', LIBS => ["@LIB_FLAGS"], ... );

    The reference to a stringified array is a little weird, I'll grant you that. But it should work. Looking at the Makefile.PL, it seems that setting the POSTGRES_LIB environment variable should work out of the box.

    • another intruder with the mooring in the heart of the Perl

      but what you want to do is quite simple: ...

      Hm. The only reference in Makefile.pl to libpq the following which comes after WriteMakeFile() has been called, and is used to check if it was detected (It is; I get no errors):

      my $output = WriteMakefile(%opts); if (!exists $output->{EXTRALIBS} or ($output->{EXTRALIBS} !~ /\-lpq/ and $output->{EXTRALIBS} !~ /libp +q/)) { my $makefile = exists $output->{MAKEFILE} ? "\nRemoving ($output->{MAKEFILE})\n" : ''; warn qq{ ========================================================== WARNING! No libpq libraries were detected! You need to install the postgresql-libs package for your system, or set the POSTGRES_LIB environment variable to the correct place. $makefile =========================================================== }; ## Do not let make proceed unlink $output->{MAKEFILE} if $makefile; exit 1; } exit 0;

      And the only references to the key LIBS in %opts as passed to WriteMakeFile() are these:

      LIBS => ["-L$POSTGRES_LIB -lpq -lm"], ... elsif ($os =~ /Win32/) { my $msdir = $POSTGRES_LIB; $msdir =~ s{"$}{/ms"}; $opts{LIBS}[0] .= " -L$msdir -lsecur32";

      So, I guess the "subtle point to my question" is how (and where/when) does -lpq get manipulated to cause it to add the reference to -llibpq?

      On the basis that it EU::MM might simply generate references to all .libs it finds in the directory denoted by $ENV{ POSTGRES_LIB }, I tried placing a copy of libpq64.lb there, but it is ignored. As are the other .lib files that are located there: postgres.lib, libpgport.lib; libecpg.lib;.

      So, something, somewhere, is telling EU::MM to generate references to libpq.lib, but I cannot see where or when that is occuring.

      The second part of my question was how to automate the choice of whether to use libpq.lib or libpq64.lib. Your pseudo-code above neatly dodges both parts of that question.

      • What goes inside your running_on_64bit()?

        Ie. How to reliably determine that the target is X64 (on Windows).

      • Where in the makefile.pl would I position your pseudo-code?

        Given I can't see where libpq.lib is being referenced (other than in the post-facto test), it's hard to see where I would incorporate your code.


      Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
      "Science is about questioning the status quo. Questioning authority".
      In the absence of evidence, opinion is indistinguishable from prejudice.
        So, I guess the "subtle point to my question" is how (and where/when) does -lpq get manipulated to cause it to add the reference to -llibpq?

        Ah, that is handled ExtUtils::Liblist which is invoked by WriteMakefile() itself. It should Just Work.

        ["-L$POSTGRES_LIB -lpq -lm"]

        Right, so libpq is hardcoded into the LIBS key's value. You shall have to interpolate something in its place instead. (Hence my conditional construct in my first snippet).

        The second part of my question was how to automate the choice of whether to use libpq.lib or libpq64.lib. Your pseudo-code above neatly dodges both parts of that question.

        And here I was hoping you wouldn't notice. I blithely assumed that this would be trivial for you. So... as for knowing whether you're on 64-bit or not, my next thought would then be to rummage through %Config and see what turns up. Other than that, I honestly don't know. But Dave "DrHyde" Cantrell would surely be happy to take on board any code you figure out, and place it in Devel::CheckOS for others to use.

        As to where you put this code, it has do be sorted out before WriteMakefile() gets called. That DBD::Pg grovels through the resulting Makefile afterwards sounds like a dreadful hack of the highest order. Also I don't know what App::Info does these days; I haven't been keeping up with the mailing lists to keep track.

        • another intruder with the mooring in the heart of the Perl

        how (and where/when) does -lpq get manipulated to cause it to add the reference to -llibpq

        You compiler (cl) doesn't understand the -l switch, so MakeMaker converts the -lpq to libpq.lib in order that your compiler will be able to make use of it. Changing the -lpq to -lpq64 in the LIBS assignment should fix things for you.

        Cheers,
        Rob

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://753039]
Approved by ELISHEVA
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others perusing the Monastery: (17)
As of 2014-07-24 18:42 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite superfluous repetitious redundant duplicative phrase is:









    Results (165 votes), past polls