Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

Re: perl510.lib needed to compile C++ code

by syphilis (Archbishop)
on Mar 15, 2022 at 12:32 UTC ( [id://11142114]=note: print w/replies, xml ) Need Help??


in reply to perl510.lib needed to compile C++ code

During compilation it is complaining perl510.lib is missing

The problem is that, with mingw-built perls, the needed import lib (which is to be found in perl/lib/CORE) is named libperl510.a, not perl510.lib.
You need to use your VS 2008 to create "libperl510.a" directly from the "perl510.dll" that you have located.
The following is modified from https://stackoverflow.com/questions/9360280/how-to-make-a-lib-file-when-have-a-dll-file-and-a-header-file. (Refer to that link first if something doesn't work. Its title is a little misleading as no header file is needed.)

Firstly, run:
dumpbin /EXPORTS perl510.dll > perl510.exports
Paste the names of the functions from perl510.exports into a new file named perl510.def. Add a line with the word EXPORTS at the top of this file.
Then, assuming that your VC environment has been properly set up (by running vcvars32.bat or whatever it is), you run:
lib /def:perl510.def /out:perl510.lib
You should get two files generated: perl510.lib and perl510.exp .
You then need to place perl510.lib somewhere where it's found - probably in perl/lib/CORE (ie in the same place as libperl510.a).

I know this procedure can work, as I've done it before. But it's something I haven't done for a long time, and I'm a bit hazy on the details.
See how you go, and report back if you get stuck.

UPDATE 1: I gave it a go using VC++ 7.0 and Strawberry Perl-5.12.2.
Seemed to go ok.
With perl510.exports, I first removed the short section of stuff at the beginning that comes before the listing of the functions begins.
And I also removed the short "Summary" section at the end.
To generate perl510.def I then ran:
perl -le "open RD, 'perl510.exports'; while (<RD>) { print (split /\s+ +/, $_)[4] }" >perl510.def
And then I manually added the EXPORTS line at the top of the file.
When I ran the lib command, I got:
C:\expt>lib /def:perl510.def /out:perl510.lib Microsoft (R) Library Manager Version 7.00.9466 Copyright (C) Microsoft Corporation. All rights reserved. LIB : warning LNK4068: /MACHINE not specified; defaulting to X86 Creating library perl510.lib and object perl510.exp
That all seems OK.

UPDATE 2: A simpler way to create the def file is to use gendef, which ships with later versions of Strawberry Perl. Just create perl510.def by running:
gendef perl510.dll
Then, as before, run:
lib /def:perl510.def /out:perl510.lib
Cheers,
Rob

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others rifling through the Monastery: (5)
As of 2024-04-24 00:50 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found