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

Installing Perl Wrapper Module for a C Library (Tree::Suffix) Locally

by monkfan (Curate)
on Mar 15, 2006 at 06:05 UTC ( [id://536784]=perlquestion: print w/replies, xml ) Need Help??

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

Hi,
I am attempting to install a CPAN module, Tree::Suffix in my local home directory. First of all I have installed the required libstree library in my particular home directory, namely $HOME/MyBioTool/libstree-0.4.2.

I have also set the environment like the following in my .bash_profile, so that the module can call it. The bash_profile looks like this:
# .bash_profile # Get the aliases and functions if [ -f ~/.bashrc ]; then . ~/.bashrc fi # My path to the C library program export CFLAGS="-I $HOME/MyBioTool/libstree-0.4.2/include" export LDFLAGS="-L $HOME/MyBioTool/libstree-0.4.2/lib" PATH=$PATH:$HOME/bin: export PATH unset USERNAME export PERL5LIB=/home/monkfan/lib/perl5/site_perl/5.8.5/i686-linux:/ho +me/monkfan/lib/perl5/site_perl/5.8.5


However, when I tried installing the Tree::Suffix module using CPAN shell, I found error message that seems to fail to recognize where does my C library is stored. It returns something like this in the end:
Running make test Can't test without successful make Running make install make had returned bad status, install seems impossible


Besides, I also tried a manual method to install the module:
~/.cpan/build/Tree-Suffix-0.12$ perl Makefile.pl CFLAGS="$CFLAGS -I$HO +ME/MyBioTool/libstree-0.4.2/include" LDFLAGS="$LDFLAGS -L$HOME/MyBioT +ool/libstree-0.4.2/lib"
Which also leads me nowhere.
Did I miss anything here?

Update: I repositioned the Makefile.PL in front, as suggested by fizbin. It gives: doesn't recognize CFLAGS as MakeMaker parameter name.
Update 2: Finally I managed to get it installed
What I did is the following steps: 1. Add this line in my .bash_profile:
export LD_LIBRARY_PATH=/home/monkfan/MyBioTool/libstree-0.4.2/lib:${L +D_LIBRARY_PATH} export CFLAGS="-I $HOME/MyBioTool/libstree-0.4.2/include"; export LDFLAGS="-L $HOME/MyBioTool/libstree-0.4.2/lib";
2. Add this line in my .bashrc :
export LIBRARY_PATH=$HOME/MyBioTool/libstree-0.4.2/lib
3. Add this line in my Makefile.PL:
__BEGIN__ use strict; use ExtUtils::MakeMaker; WriteMakefile( NAME => 'Tree::Suffix', VERSION_FROM => 'lib/Tree/Suffix.pm', ABSTRACT_FROM => 'lib/Tree/Suffix.pm', AUTHOR => 'gray <gray@cpan.org>', PREREQ_PM => { 'Test::More' => 0 }, LIBS => [ '-L/home/monkfan/MyBioTool/libstree-0.4.2/lib -ls +tree' ], INC => '-I/home/monkfan/MyBioTool/libstree-0.4.2/include' + , clean => { FILES => 'Tree-Suffix-*' }, dist => { COMPRESS => 'gzip -9f', SUFFIX => 'gz', }, ); __END__
4. Do this:
$ perl Makefile.PL PREFIX=~/lib/ LIB=~/lib/ OR $ perl Makefile.PL PREFIX=~/lib/perl5/site_perl/5.8.5 LIB=~/lib/perl5/ +site_perl/5.8.5
Depending on the location you wish to install.
5. Followed by standard: make, make test, make install

Regards,
Edward

Replies are listed 'Best First'.
Re: Installing Perl Wrapper Module for a C Library (Tree::Suffix) Locally
by bowei_99 (Friar) on Mar 15, 2006 at 07:20 UTC
    A couple things -
    1. You say installing manually leads you nowhere - can you give more details? Like what specific error messages, etc...
    2. I think if the variables are set correctly, as it seems they are in your ~/.bashrc, you can just run
      perl Makefile.PL make make test
    3. If you aren't sure, you can type
       source ~/.bashrc
      then type printenv, and check that the variables are set correctly.

      Also, I was able to download and install libstree from the link in your post, after which I was able to install Tree::Suffix without a problem, using the default settings. I didn't need to set of the settings like you did in your .bashrc file. Do you need to install in your home directory? If not, you can try with the default settings suggested in the docs, and see if that works.

      -- Burvil

      Hi,
      Thanks for your answer. To answer your point:
      Like what specific error messages, etc...
      It gives:
      Can't open perl script "CFLAGS=-I /home/ewijaya/MyBioTool/libstree-0. +4.2/include": No such file or directory. Use -S to search $PATH for it.
      I think if the variables are set correctly, as it seems they are in your ~/.bashrc, you can just run
      No, they are in my .bash_profile. Running those command you suggest also gave exactly the same error message as in my OP.
      then type printenv, and check that the variables are set correctly.
      Here is what I have:

      And no, I don't have a SU previlege. So I have no choice but to install it locally.
      Update: corrected "ewijaya" to "monkfan", that value I manually replace them.

      Regards,
      Edward
        Two things -

        1. Hm, I get the sense you come from a C background. If that's right, I can see why you would pass the flags as a parameter to perl. However, when it says

         Can't open perl script "CFLAGS=-I /home/ewijaya/MyBioTool/libstree-0.
        +4.2/include": No such file or directory.
        
        I think it's interpreting your command as the flags being the script, and since that's not what you want, nor will it work, it gives an error. I'd say cd to the place where you untarred the Tree::Suffix install files, and run perl Makefile.pl, and see what happens. If that works, try make, then make test.

        2. Re: your variables, look at:

        LDLAGS=LDFLAGS-L/home/ewijaya/MyBioTool/libstree-0.4.2/lib .... CFLAGS=-I/home/monkfan/MyBioTool/libstree-0.4.2/include
        See how LDFLAGS is different from what you have set in your .bash_profile? (Which, by the way, I think .bash_profile is for login only; if you make the changes to ~/.bashrc, you don't need to logout and log back in for changes to take effect, you can just do source ~/.bashrc. See here for more info (from a google search for .bash_profile).

        So, you need to fix LDFLAGS... not sure why it's happening for you; although when that sort of thing has happened to me before, it was because I mistyped a command to set a variable that had already been set in my .bashrc file. To do a quick fix, you could try running the line from your .bash_profile, and seeing if it's set correctly, like so -

        prompt> export LDFLAGS="-L $HOME/MyBioTool/libstree-0.4.2/lib" prompt> printenv LDFLAGS |---> this command should give you: -L $HOME/MyBioTool/libstree-0.4.2/lib

        -- Burvil

Re: Installing Perl Wrapper Module for a C Library (Tree::Suffix) Locally
by fizbin (Chaplain) on Mar 15, 2006 at 15:15 UTC

    I would very much like to see the first error that the CPAN shell gets - the errors you quote aren't useful. (They basically boil down to "something went wrong earlier").

    That being said, your manual compilation attempt won't succeed because the first argument to perl isn't a perl script. Re-order your arguments and put Makefile.PL at the front:

    ~/.cpan/build/Tree-Suffix-0.12$ perl Makefile.PL CFLAGS="$CFLAGS -I$HO +ME/MyBioTool/libstree-0.4.2/include" LDFLAGS="$LDFLAGS -L$HOME/MyBioT +ool/libstree-0.4.2/lib"
    followed by the command make and, only if the previous command was successful, make test and then (again, only if make test was successful) make install.
    --
    @/=map{[/./g]}qw/.h_nJ Xapou cets krht ele_ r_ra/; map{y/X_/\n /;print}map{pop@$_}@/for@/
      Actually, since those variables should already be defined, according to your earlier posts, all you should need to type is
      perl Makefile.PL $CFLAGS $LDFLAGS
      To make sure the variables are set correctly you can type
      printenv | grep FLAGS
      If they aren't set correctly, you can run the export command in an earlier posting to fix it.

      Also, if you don't want to sit around and wait (although for troubleshooting purposes, it's probably better to do so), you can type

      perl Makefile.PL $CFLAGS $LDFLAGS && make && make test && make install
      The && means that the command will only execute if the previous one was OK.

      -- Burvil

        I think you meant
        perl Makefile.PL "CFLAGS=$CFLAGS"
        etc.

        But in any case, this doesn't matter, since Makefile.PL doesn't accept CFLAGS or LDFLAGS as arguments.

        --
        @/=map{[/./g]}qw/.h_nJ Xapou cets krht ele_ r_ra/; map{y/X_/\n /;print}map{pop@$_}@/for@/
      I would very much like to see the first error that the CPAN shell gets
      Hi fizbin,
      This is the error I got: Running simple command:
      $ perl Makefile.PL $ make $ make install
      gave the same error as above

      Regards,
      Edward

        The problematic line is this line:

        Note (probably harmless): No library found for -lstree

        I don't know why MakeMaker outputs this "propably harmless" message, because in my experience, it has never been harmless whenever I encountered it. This error message means that the Makefile.PL could not find the library stree, most likely because you didn't supply the correct -L and -I switches to it. This seems especially valid as your stree library is installed in an uncommon path I think.

        You will have to run your Makefile.PL manually and supply the correct paths to where the header/include files of the stree library got installed. Most likely like:

        perl -w Makefile.PL "INCLUDE=-I ../stree/include" "LIBS=-L ../stree/li +b"

        Okay, so it would appear that Makefile.PL and CPAN are not honoring your cflags environment setting. Furthermore, it appears that you need to pass extra C flag arguments to Makefile.PL as "CCFLAGS", not "CFLAGS". So, I would suggest trying this:

        perl Makefile.PL CCFLAGS="$CFLAGS" LDFLAGS="$LDFLAGS"
        That should produce a Makefile that you can use with "make".
        --
        @/=map{[/./g]}qw/.h_nJ Xapou cets krht ele_ r_ra/; map{y/X_/\n /;print}map{pop@$_}@/for@/
Re: Installing Perl Wrapper Module for a C Library (Tree::Suffix) Locally
by bowei_99 (Friar) on Mar 15, 2006 at 17:20 UTC
    As noted by fizbin, Makemaker doesn't take that as a parameter, which is why you're getting that message in your update. Try running only perl Makefile.PL then make, then make test, then make install, and check to make sure that each step was without errors. I think that will work, as if you look at the README for Tree::Suffix, it doesn't say to include any parameters.

    -- Burvil

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others musing on the Monastery: (3)
As of 2024-04-19 06:07 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found