digitalmars.D.learn - D CGI test: linux.so.2: bad ELF interpreter: No such file or directory
- Nick Sabalausky (26/26) Apr 25 2011 I've made a little test CGI app:
- Robert Clipsham (11/22) Apr 25 2011 This is probably occurring due to different versions of dynamic
- Nick Sabalausky (3/27) Apr 25 2011 Thanks. How would I statically link against libc?
- Robert Clipsham (7/8) Apr 26 2011 The way to do this with C is to pass -static to gcc, and I recall doing
- Nick Sabalausky (7/12) Apr 26 2011 Hmm, that doesn't seem to work, I just get:
- Spacen Jasset (5/10) Apr 26 2011 Its not recommended you statically link to libc at any time except for
I've made a little test CGI app: import std.conv; import std.stdio; void main() { auto content = "<b><i>Hello world</i></b>"; auto headers = `HTTP/1.1 200 OK Content-Type: text/html; charset=UTF-8 Content-Length: `~to!string(content.length); while(readln().length > 1) {} writeln(headers); writeln(); writeln(content); } Works on Windows command line and through IIS. And it works on my Kubuntu 10.6 command line. But if I copy the executable from my Kubuntu box to my web host's Debian server: Running it through Apache gives me a 500, and running it directly with ssh gives me: linux.so.2: bad ELF interpreter: No such file or directory I assume that error message is the cause of the 500 (can't tell for sure because the 500 isn't even showing up in my Apache error logs). But I'm not enough of a linux expert to have the slightest clue what that error message is all about. I don't need to actually compile it *on* the server do I? I would have thought that all (or at least most) Linux distros used the same executable format - especially (K)Ubuntu and Debian.
Apr 25 2011
On 25/04/2011 21:38, Nick Sabalausky wrote:Works on Windows command line and through IIS. And it works on my Kubuntu 10.6 command line. But if I copy the executable from my Kubuntu box to my web host's Debian server: Running it through Apache gives me a 500, and running it directly with ssh gives me: linux.so.2: bad ELF interpreter: No such file or directory I assume that error message is the cause of the 500 (can't tell for sure because the 500 isn't even showing up in my Apache error logs). But I'm not enough of a linux expert to have the slightest clue what that error message is all about. I don't need to actually compile it *on* the server do I? I would have thought that all (or at least most) Linux distros used the same executable format - especially (K)Ubuntu and Debian.This is probably occurring due to different versions of dynamic libraries on the kubuntu and debian boxes. ldd <executable> will tell you which versions the application is linking against, it's probably libc that's the issue, or one of the other core libraries. The solution is either to link against the correct library version, or statically link the version you need. Most likely the version of debian on the server uses an older library, which you'll need to link against. -- Robert http://octarineparrot.com/
Apr 25 2011
"Robert Clipsham" <robert octarineparrot.com> wrote in message news:ip4nhc$2mdp$1 digitalmars.com...On 25/04/2011 21:38, Nick Sabalausky wrote:Thanks. How would I statically link against libc?Works on Windows command line and through IIS. And it works on my Kubuntu 10.6 command line. But if I copy the executable from my Kubuntu box to my web host's Debian server: Running it through Apache gives me a 500, and running it directly with ssh gives me: linux.so.2: bad ELF interpreter: No such file or directory I assume that error message is the cause of the 500 (can't tell for sure because the 500 isn't even showing up in my Apache error logs). But I'm not enough of a linux expert to have the slightest clue what that error message is all about. I don't need to actually compile it *on* the server do I? I would have thought that all (or at least most) Linux distros used the same executable format - especially (K)Ubuntu and Debian.This is probably occurring due to different versions of dynamic libraries on the kubuntu and debian boxes. ldd <executable> will tell you which versions the application is linking against, it's probably libc that's the issue, or one of the other core libraries. The solution is either to link against the correct library version, or statically link the version you need. Most likely the version of debian on the server uses an older library, which you'll need to link against.
Apr 25 2011
On 26/04/2011 00:05, Nick Sabalausky wrote:Thanks. How would I statically link against libc?The way to do this with C is to pass -static to gcc, and I recall doing something similar with dmd to get it working (maybe -L-static?) - I don't have a linux machine near me to test with though, sorry. -- Robert http://octarineparrot.com/
Apr 26 2011
"Robert Clipsham" <robert octarineparrot.com> wrote in message news:ip623p$23in$1 digitalmars.com...On 26/04/2011 00:05, Nick Sabalausky wrote:Hmm, that doesn't seem to work, I just get: /usr/bin/ld: cannot find -lgcc_s collect2: ld returned 1 exit status --- errorlevel 1 I think I'm going to start a new thread for this...Thanks. How would I statically link against libc?The way to do this with C is to pass -static to gcc, and I recall doing something similar with dmd to get it working (maybe -L-static?) - I don't have a linux machine near me to test with though, sorry.
Apr 26 2011
On 26/04/2011 10:05, Robert Clipsham wrote:On 26/04/2011 00:05, Nick Sabalausky wrote:Its not recommended you statically link to libc at any time except for operating system applications. It may work, it may crash etc. The way to do this is to link against the oldest libc you need to support, thus making the binaries forward compatible.Thanks. How would I statically link against libc?The way to do this with C is to pass -static to gcc, and I recall doing something similar with dmd to get it working (maybe -L-static?) - I don't have a linux machine near me to test with though, sorry.
Apr 26 2011