Web Servers on Unix and Linux - Problems using MySQL client via Apache CGI

This is Interesting: Free IT Magazines  
Home > Archive > Web Servers on Unix and Linux > June 2004 > Problems using MySQL client via Apache CGI





You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

Author Problems using MySQL client via Apache CGI
Griff

2004-06-06, 7:54 am

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

2004-06-06, 4:55 pm

In alt.apache.configuration Griff <griffph@aol.com> wrote:
> Any ideas of how I might start investigating this would be
> appreciated.


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.
|
|
Sundaram Ramasamy

2004-06-08, 12:03 am

griffph@aol.com (Griff) wrote in message news:<d698d3e7.0406060355.4ef11469@posting.google.com>...
> 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


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
Griff

2004-06-09, 5:03 pm

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

Cheers - Griff
Sponsored Links






Free braindumps | Software forum | Database administration forum

Copyright 2003 - 2008 webservertalk.com