Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

Re: Win32/MingW SetupAPI usage woes with Inline::C

by syphilis (Archbishop)
on Apr 23, 2018 at 04:03 UTC ( [id://1213403]=note: print w/replies, xml ) Need Help??


in reply to Win32/MingW SetupAPI usage woes with Inline::C

undefined reference to `__imp_SetupDiGetClassDevsA'


I think the problem is the line:
libs => '-LC:\\MinGW\\lib -lSetupAPI',
I think it might be finding the wrong libsetupapi.a.
Try replacing that line with:
libs => '-lsetupapi',
The correct 'libsetupapi.a' is in a location that should be found by default - so there should be no need to specify a location for it.
At least, for me, when I made that change to your script, it built just fine. Prior to that I was getting the same error as you.

Cheers,
Rob

Replies are listed 'Best First'.
Re^2: A workaround, but not really a fix
by tlhackque (Beadle) on May 31, 2018 at 01:35 UTC

    Thanks. Sorry I didn't see this sooner.

    I tried that first. So, after reading your note I searched the entire C: drive (where MinGW is installed).

    I found another libsetupapi.a in C:\Perl-5.22.1-64\site\lib\auto\MinGW\x86_64-w64-mingw32\lib

    And specifying that does compile. Apparently Inline::C installs it there. But hardcoding a path makes this very unportable to another system.

    So, the new question is: how do I get that path portably?

    I can use Config; $Config{sitelibexp} for part of the way: 'C:\Perl-5.22.1-64\site\lib' (which also appears in @INC)

    But this is magic: "\auto\MinGW\x86_64-w64-mingw32\lib" There some pkg-config -like method for Perl...

    For now, I use this expensive hack

    use File::Find; my $libpath; my $incpath; BEGIN { find( { wanted => sub { /^libsetupapi\.a$/i && ($libpath ||= $File::Find::dir); /^setupapi\.h$/i && ($incpath ||= $File::Find::dir); }, follow => 1, follow_skip => 2 }, @INC ); die( "No MinGW libsetupapi $libpath $incpath\n" ) unless( $libpath && $incpath ); } use Inline( C => Config => libs => "-L$libpath -lSetupAPI", INC => "-I$incpath", );

    There must be a better way. Meantime, on to figuring out the mysteries of the Windoze APIs.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1213403]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (4)
As of 2024-04-20 04:05 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found