Problems using MySQL client via Apache CGI

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Griff

    #1

    Problems using MySQL client via Apache CGI

    Hi there

    I'm trying to run some CGI programs under Apache, written in C++,
    which use the "libmysqlclient " MySQL library. This is all running on
    Solaris.

    I build my programs using the following makefile:

    all: SCM exampleSQL

    SCM: SCM.cpp makefile
    @echo "Building SCM"
    g++ SCM.cpp -g -o SCM -I/usr/local/include/mysql
    -L/usr/local/lib/mysql -lmysqlclient -lz
    chmod 555 SCM
    cp SCM ../cgi-bin

    exampleSQL: exampleSQL.cpp makefile
    @echo "Building exampleSQL"
    g++ -o exampleSQL exampleSQL.cpp -I/usr/local/include/mysql
    -L/usr/local/lib/mysql -lmysqlclient -lz
    chmod 555 exampleSQL
    cp exampleSQL ../cgi-bin

    where "SCM" is the production program, and "exampleSQL " is a test
    program I have written to try and get things working.

    As you can see these two programs are compiled identically. When I run
    program "exampleSQL ", everything is fine, it pulls all the stuff out
    of the database and sends everything back to my web browser.

    But when I try to run program "SCM", I get an Apache error, and when I
    look in /var/apache/logs/error_log I get:
    ld.so.1: SCM: fatal: libmysqlclient. so.12: open failed: No such file
    or directory
    [Sun Jun 6 12:34:36 2004] [error] [client 172.17.1.234] Premature end
    of script headers: /var/apache/cgi-bin/SCM

    How can one program manage to find the correct library at runtime but
    not the other ? Permissions ? Or is it dependent on exactly which
    MySQL functions the program tries to call ? (NB I have a SetEnv for
    LD_LIBRARY_PATH in httpd.conf which I hoped would fix this but
    doesn't.)

    Any ideas of how I might start investigating this would be
    appreciated.

    Best rgds

    Griff
  • Davide Bianchi

    #2
    Re: Problems using MySQL client via Apache CGI

    In alt.apache.conf iguration Griff <griffph@aol.co m> wrote:[color=blue]
    > Any ideas of how I might start investigating this would be
    > appreciated.[/color]

    I'd suggest to compile the program statically linked instead
    of dynamically. It will become way bigger, but you'll solve
    all the dynamic linking problems at once.
    Davide

    --
    | Turnaucka's Law: The attention span of a computer is only as long as
    | its electrical cord.
    |
    |

    Comment

    • Sundaram Ramasamy

      #3
      Re: Problems using MySQL client via Apache CGI

      griffph@aol.com (Griff) wrote in message news:<d698d3e7. 0406060355.4ef1 1469@posting.go ogle.com>...[color=blue]
      > Hi there
      >
      > I'm trying to run some CGI programs under Apache, written in C++,
      > which use the "libmysqlclient " MySQL library. This is all running on
      > Solaris.
      >
      > I build my programs using the following makefile:
      >
      > all: SCM exampleSQL
      >
      > SCM: SCM.cpp makefile
      > @echo "Building SCM"
      > g++ SCM.cpp -g -o SCM -I/usr/local/include/mysql
      > -L/usr/local/lib/mysql -lmysqlclient -lz
      > chmod 555 SCM
      > cp SCM ../cgi-bin
      >
      > exampleSQL: exampleSQL.cpp makefile
      > @echo "Building exampleSQL"
      > g++ -o exampleSQL exampleSQL.cpp -I/usr/local/include/mysql
      > -L/usr/local/lib/mysql -lmysqlclient -lz
      > chmod 555 exampleSQL
      > cp exampleSQL ../cgi-bin
      >
      > where "SCM" is the production program, and "exampleSQL " is a test
      > program I have written to try and get things working.
      >
      > As you can see these two programs are compiled identically. When I run
      > program "exampleSQL ", everything is fine, it pulls all the stuff out
      > of the database and sends everything back to my web browser.
      >
      > But when I try to run program "SCM", I get an Apache error, and when I
      > look in /var/apache/logs/error_log I get:
      > ld.so.1: SCM: fatal: libmysqlclient. so.12: open failed: No such file
      > or directory
      > [Sun Jun 6 12:34:36 2004] [error] [client 172.17.1.234] Premature end
      > of script headers: /var/apache/cgi-bin/SCM
      >
      > How can one program manage to find the correct library at runtime but
      > not the other ? Permissions ? Or is it dependent on exactly which
      > MySQL functions the program tries to call ? (NB I have a SetEnv for
      > LD_LIBRARY_PATH in httpd.conf which I hoped would fix this but
      > doesn't.)
      >
      > Any ideas of how I might start investigating this would be
      > appreciated.
      >
      > Best rgds
      >
      > Griff[/color]

      You may be doing this already.

      You need to set LD_LIBRARY_PATH in apache startup shell script. use
      ldd or dump commnd to check the dynamic object path. or you change
      system wide dynamic object search path.

      -SR

      Comment

      • Griff

        #4
        Re: Problems using MySQL client via Apache CGI

        Thanks to everyone for all your help with this, some good pointers there.

        Cheers - Griff

        Comment

        Working...