in reply to linking C/C++ lib with Perl h2xs XSUBs.

lib cr libmylib.lib mylib.obj

Check that the makefile assigns simply lib to AR. I suspect it is assigning lib cr

I don't know how this error is arising (someone else might), but I think the lib command will succeed if the cr is removed. You could check by cd'ing to the folder that contains mylib.obj and running lib libmylib.lib mylib.obj
Then cd back to the top level folder and run nmake again.

Cheers,
Rob

Replies are listed 'Best First'.
Re^2: linking C/C++ lib with Perl h2xs XSUBs.
by Anonymous Monk on Feb 18, 2009 at 05:12 UTC
    The OP is introducing it with sub MY::top_targets
    $(AR) cr libmylib$(LIB_EXT) $(O_FILES)
Re^2: linking C/C++ lib with Perl h2xs XSUBs.
by Anonymous Monk on Feb 18, 2009 at 05:24 UTC
    I removed the cr command and used lib libmylib.lib mylib.obj in the cmd promot:
    Below is the error msg:
    C:\Perl\bin\MyTest2\mylib>lib libmylib.lib mylib.obj
    Microsoft (R) Library Manager Version 8.00.50727.42
    Copyright (C) Microsoft Corporation. All rights reserved.
    LIB : fatal error LNK1104: cannot open file 'libmylib.lib'
      LIB : fatal error LNK1104: cannot open file 'libmylib.lib'

      Yes - it thinks that libmylib.lib is an input file. Based on the lib /? documentation, the following is probably what's needed: lib /out:libmylib.lib mylib.obj

      Cheers,
      Rob
        Hi! I followed the same procedure but I am still seeing the same error message after running nmake test.
        LINK : fatal error LNK1104: cannot open file 'libmylib.lib'
        This is my Makefile.PL
        use ExtUtils::MakeMaker; $Verbose = 1; WriteMakefile( NAME => 'Mytest2::mylib', SKIP => [qw(all static static_lib dynamic dynamic_lib)], clean => {'FILES' => 'libmylib$(LIBEEXT)'}, MYEXTLIB => 'mylib/libmylib$(LIB_EXT)', ); sub MY::top_targets { ' all :: static pure_all :: static static :: libmylib$(LIB_EXT) libmylib$(LIB_EXT): $(O_FILES) $(AR) libmylib$(LIB_EXT) $(O_FILES) $(RANLIB) libmylib$(LIB_EXT) '; }
        What is wrong here? Thanks.