Re: Static library works everywhere but server
- From: gordonb.96lli@xxxxxxxxxxx (Gordon Burditt)
- Date: Thu, 10 Jul 2008 14:58:42 -0500
I must be forgetting something (up all night).
I installed sqlite database on FreeBSD. Wrote a small piece of code
to read two columns and it works. Transferred to an Ubuntu box and
recompiled. It works there, too. Uploaded to my hosts server, which
is CentOS, but, when accessing the page, I get a "Premature end of
headers" 500 error.
Usually I'll get this error if I forget to send the http headers but
this isn't the case here.
Another common cause for that type of error is an error message
generated *BEFORE* the headers but not in the proper format for
headers. This would include linker complaints about not being able
to find shared libraries. It might also include snide library
comments about gets() being deprecated and being unsafe to use (it
*IS* unsafe to use). With Perl, it may include complaints about
missing include files.
It is also possible to get that error with permission problems on
the executable or any directories above it. Note that with Apache
permissions that are too liberal (e.g. writable by everyone) are
as bad as permissions that are too strict.
When I initially set up sqlite on my boxes, I do:
./configure --disable-shared --enable-static (from a post on Apple's
board)
sudo make install
I get libsqlite3.a, along with libsqlite3.so in /usr/local/lib.
Then:
gcc -c mycode.c
gcc -L/usr/local/lib mycode.o -lsqlite3 -o mycode
Running all that gives me an executable that prints out the correct
values on FreeBSD and Ubuntu but gives the error mentioned above.
If "mycode.c" is rewritten to just printf("hello world"); but without
linking to sqlite, it works correctly on the server. The only thing
"mycode" does is extract a value from the database and prints it.
The simple database of two values is loaded on the server in the same
folder (cgi-bin).
One way to *TRY* to test this is to emulate the web server. su to
the user that Apache or whatever it is runs as, and try to manually
execute the CGI, setting up the environment variables just as Apache
would. If you get warnings or errors *before* the headers, or
forget the blank line between the headers and the content, this is
a problem. Note that on leased space on a server, you may not be
able to do this test.
Also, try to find something meaningful in the server logs.
The static library is about 1Mb, so I would have thought the
executable would be about the same but it's only 7K. I'm thinking
it's linking with the shared libraries instead? If I compile with -
static, I get a bunch of errors for functions using pthread.
At that point, I have to take a nap. Been up all night and this was
the last thing to do.
.
- Follow-Ups:
- Re: Static library works everywhere but server
- From: drhowarddrfine
- Re: Static library works everywhere but server
- References:
- Static library works everywhere but server
- From: drhowarddrfine
- Static library works everywhere but server
- Prev by Date: determining Cygwin environment
- Next by Date: killing process on AIX
- Previous by thread: Re: Static library works everywhere but server
- Next by thread: Re: Static library works everywhere but server
- Index(es):
Relevant Pages
|
Loading