4

I built a .CGI in C++. This binary depends on some boost shared library and other resources in a specific folder /usr/local/boost/. The CGI doesn't execute and in the log I can see the error

    error while loading shared libraries: libdxxx: cannot 
    open shared object file: No such file or dire

Now, I've read many logs that say that I have to set in httpd.conf the following, but still doesn't work.

   SetEnv LD_LIBRARY_PATH /usr/local/boost:

In my config I set this line "as it is" at the end of the config file without being included in any VirtualHOst or Directory section. I tried to insert into the Directory for the cgi-bin but still the same

 <Directory "/var/www/cgi-bin">
     AllowOverride None
     Options None
     Order allow,deny
     Allow from all
     SetEnv LD_LIBRARY_PATH /usr/local/boost
 </Directory>

I have also tried (see discurrion below) to add a .conf file for ldconfig but it still doesn't work!

  #added a file called myconfig.conf conrtaining a line
  /usr/local/boost 

  /etc/ld.conf.d/
  ldconfig (as root)

I have also reead that httpd inherits the environment variable of the ROOT user that runs it; as I root I call the following to start Apache and LD_LIBRARY_PATH is correctly set but still something is wrong.

 /etc/init.d/httpd start

I am using Red Hat 6.2.

Abruzzo Forte e Gentile
  • 14,423
  • 28
  • 99
  • 173

1 Answers1

5

In our Linux Debian box, we use this:

Create a config file, add string /usr/local/boost in it:

/etc/ld.so.conf.d/boost.conf

Then run:

# ldconfig

And finally:

# /etc/init.d/apache2 restart

I don't know how to do it in Red Hat.

jacouh
  • 8,473
  • 5
  • 32
  • 43
  • Hi Jacouh! Thanks a lot. This will solve the issue but it will automatically change or the library search path for all my applications. Do you know if there is another solution? – Abruzzo Forte e Gentile Oct 21 '13 at 08:31
  • Can you regroup all your personal .so in some reasonnable number of directories and add all them in a config file line per line ? – jacouh Oct 21 '13 at 08:32
  • I'll try that. Hoping to not have impact on the group of people I am working with. Anyway is it a solution to my problem AND a gave me thougts about a better planning for folders for the future. – Abruzzo Forte e Gentile Oct 21 '13 at 08:34
  • Have you commented SetEnv LD_LIBRARY_PATH /opt/ibm/db2/V9.7/lib64 ? or copy all your .so's in /usr/local/lib ? – jacouh Oct 21 '13 at 08:50
  • Hi jacouh. Yes I did that (and corrected a small typo in my mail) – Abruzzo Forte e Gentile Oct 21 '13 at 09:23
  • Hi Jacouh..at the end I switched to MONGOOSE. It is a binary running on the same shell like a program and it works immediately..not happy of the solution but it does the job. – Abruzzo Forte e Gentile Oct 22 '13 at 11:06
  • Apache is a big and universal server with multiple modules. + All these developpers for help. For a production site, it's better ? – jacouh Oct 22 '13 at 11:41
  • I'll tell you as soon as we'll use it massively. For now I am not able to do an evaluation. Anycase I agree with you Apache is de facto a standard and I should better understand it. – Abruzzo Forte e Gentile Oct 23 '13 at 10:41
  • Genius ! That was the only thing that worked after trying numerous suggested solutions. My problem was SSL libraries not getting included in a Python web cgi. This works for that. – blissweb Jul 09 '20 at 10:59