Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

perl510.lib needed to compile C++ code

by rakesh (Initiate)
on Mar 15, 2022 at 10:47 UTC ( [id://11142104]=perlquestion: print w/replies, xml ) Need Help??

rakesh has asked for the wisdom of the Perl Monks concerning the following question:

Hi, I am using VS 2008 VC++ code in project that calls perl script. We are using perl 5.10. During compilation it is complaining perl510.lib is missing. I can see perl510.dll present in strawberry\bin folder though. In Strawberry Perl installer I can see perl510.dll but not perl510.lib. Please can you help me getting the same or let me know if I can I compile strawberry perl code locally to generate lib files. That will help me in moving ahead with the project. Regards Rakesh

Replies are listed 'Best First'.
Re: perl510.lib needed to compile C++ code
by syphilis (Archbishop) on Mar 15, 2022 at 12:32 UTC
    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
Re: perl510.lib needed to compile C++ code
by cavac (Parson) on Mar 15, 2022 at 11:42 UTC

    You got more problems than just a missing .lib file. Perl 5.10 is out of support since 2009-08-23. Visual Studio 2008 is out of support since 2018-04-10. Both programs had, in newer version, major security updates since then.

    That pretty much guarantees that both your development environment and any software you make with your tools will have major security problems.

    I think it is time to upgrade.

    perl -e 'use Crypt::Digest::SHA256 qw[sha256_hex]; print substr(sha256_hex("the Answer To Life, The Universe And Everything"), 6, 2), "\n";'
Re: perl510.lib needed to compile C++ code
by Anonymous Monk on Mar 15, 2022 at 11:02 UTC

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://11142104]
Approved by marto
Front-paged by Corion
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others taking refuge in the Monastery: (5)
As of 2024-04-24 20:06 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found