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

Hi it seems easy but it drives me crazy: I have a perl module using Text:Unaccent which I compiled. I installed libiconv as well. Now when I run a script using my module it gives me: Can't load '/usr/lib64/perl5/site_perl/5.8.5/x86_64-linux-thread-multi/auto/Text/Unaccent/Unaccent.so' for module Text::Unaccent: libiconv.so.2: cannot open shared object file: No such file or directory at /usr/lib64/perl5/5.8.5/x86_64-linux-thread-multi/DynaLoader.pm line 230. What is wrong? I have libiconv.so and libiconv.2.so in /usr/lib and /usr/local/lib When I print the LD_LIBRARY_PATH enviroment variable I get /usr/lib:/usr/local/lib Please help ? :)

Replies are listed 'Best First'.
Re: libiconv wont work :(
by ikegami (Patriarch) on Dec 06, 2010 at 16:11 UTC
    In the error message, it says libiconv.so.2. In your report, you said libiconv.2.so. Is that a typo?
Re: libiconv wont work :(
by moritz (Cardinal) on Dec 06, 2010 at 14:54 UTC
Re: libiconv wont work :(
by locked_user sundialsvc4 (Abbot) on Dec 06, 2010 at 15:00 UTC

    Couple things to look at:

    1. If you are new to installing modules with CPAN, be patient.   It is an acquired taste.
    2. Make sure that you know where the modules (like Text::Unaccent actually have been placed.   Validate that they actually are there.   Make sure that you did the entire module-install process and that all of it worked.
    3. Once you are sure that the modules were correctly installed into some directory, be sure that it’s in @INC.
    4. “Well, mistakes sometimes do happen.”   A module is supposed to name all of its prerequisites and co-requisites correctly, but, the possibility remains that maybe something got overlooked.   Every now and then, you will encounter a situation where you find that something is missing and have to install it.   (Once you have installed the prereq, re-install the dependent module again.)   I do not know whether this sort of thing did happen here, but it can.

      Yeah I used CPAN and it passed... And I check there are Unaccent.so files in perl modules as well as Unaccent.pm ... This really gives me a headache
Re: libiconv wont work :(
by Anonymous Monk on Dec 06, 2010 at 16:20 UTC
    What do

    $ ldd /usr/lib64/perl5/site_perl/5.8.5/x86_64-linux-thread-multi/aut +o/Text/Unaccent/Unaccent.so
    and

    $ strace -f -efiles ldd /usr/lib64/perl5/site_perl/5.8.5/x86_64-linu +x-thread-multi/auto/Text/Unaccent/Unaccent.so 2>&1 | grep libiconv
    say?
      yeah it was a typo... (it is of course libiconv.so.2) the first command outputs:
      libiconv.so.2 => not found libc.so.6 => /lib64/tls/libc.so.6 (0x0000002a95679000) /lib64/ld-linux-x86-64.so.2 (0x000000552aaaa000)
      the second one nothing at all... It is missing the link to libiconv.so.2 somehow eventhough it is on the system. I tried export(LD_LIBRARY_PATH)="/usr/lib:/usr/local/lib" and running a perl script from cmd line and it worked! But it doesnt work on my "real" website script even if I do ENV{'LD_LIBRARY_PATH'}="/usr/lib:/usr/local/lib"

        You have a couple of options. One would be to uninstall your CPAN module, make sure you use your distribution's package manage to install libiconv, then rebuild the CPAN modules so that they will use the OS paths for the libraries.

        If you want to use the libiconv that you built yourself, then what you can do (you have to be root to do this) is to add /usr/local/lib to your /etc/ld.so.conf. If you have a Red Hat or Red Hat like system (CentOS, Fedora) then you can simply add a new file in /etc/ld.so.conf.d named anything you want (but in this case usrlocal.conf would be good)with the contents:

        /usr/local/lib

        Since you want this to work for your web server and Perls spawned by it (I'm guessing Apache), then what you can do is in your httpd.conf specify the environment variable to be passed on using this syntax:

        SetEnv LD_LIBRARY_PATH /usr/lib:/usr/local/lib

        I only list /usr/lib and /usr/local/lib, but you'll want every path to be included in there, because setting LD_LIBRARY_PATH overrides the complete value used by all programs spawned by the web server (not just Perl). Not specifying everything could lead to Big Problems for CGI executables.

        Most likely, changing %ENV is only respected when launching new processes by your OS, and does not affect a currently running process. Either launch your process through a shell script wrapper that sets up the environment, or restart your Perl program by using (something like) exec $0 => @ARGV. The second approach might fail when $0 does not resolve to a valid filename.

        the second outputs:
        [pid 20181] open("/lib64/tls/x86_64/libiconv.so.2", O_RDONLY) = -1 ENO +ENT (No such file or directory) [pid 20181] open("/lib64/tls/libiconv.so.2", O_RDONLY) = -1 ENOENT (No + such file or directory) [pid 20181] open("/lib64/x86_64/libiconv.so.2", O_RDONLY) = -1 ENOENT +(No such file or directory) [pid 20181] open("/lib64/libiconv.so.2", O_RDONLY) = -1 ENOENT (No suc +h file or directory) [pid 20181] open("/usr/lib64/tls/x86_64/libiconv.so.2", O_RDONLY) = -1 + ENOENT (No such file or directory) [pid 20181] open("/usr/lib64/tls/libiconv.so.2", O_RDONLY) = -1 ENOENT + (No such file or directory) [pid 20181] open("/usr/lib64/x86_64/libiconv.so.2", O_RDONLY) = -1 ENO +ENT (No such file or directory) [pid 20181] open("/usr/lib64/libiconv.so.2", O_RDONLY) = -1 ENOENT (No + such file or directory) libiconv.so.2 => not found
      $ strace -f -efiles ... ^
      sorry, typo - should be -efile (no 's')