4

As mentioned in this thread as well as here I am using mkbundle -o newfile oldfile.exe --static (OS: Ubuntu 11.10 64bit, Mono: 2.10.5) to create a file which shall be executable on an Apache Web Server (OS: Debian GNU/Linux 32bit). Here, the oldfile.exe was the result of the compilation of a C#-Hello-World-Code using mcs oldfile.cs. On the original system (with Ubuntu) the file is executable. However, whenver I call newfile on the Apache Web Server I get the error:

cannot execute binary file

Also, when doing file newfile it says

ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked (uses shared libs), not stripped

I suspect if mkbundle worked as it is supposed to, then it should have read

... statically linked ...

shouldn't it? Anyone an idea why the file is not executable on the Server? Is it a problem because of 32bit/64bit?

Community
  • 1
  • 1
tyrex
  • 8,208
  • 12
  • 43
  • 50
  • I call the application with PHP using `./newfile` or `sh newfile`. I have tried both these options with the three PHP-commands `exec/passthru/system`. Every time the same error `cannot execute binary file` occurs (I read the errors out in the apache-error-log). – tyrex Feb 09 '12 at 16:24
  • 1
    Can you show `file newfile`? Is your server system 32bit? – wRAR Feb 09 '12 at 16:26
  • Good idea. The output of `file newfile` on the server is `ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked (uses shared libs), not stripped` . As for the server system, I have to find out if it is 32 or 64bit and will get back with that info. When I use the same command on the building machine (Ubuntu) it gives the same plus `for GNU/Linux 2.6.15`. Perhaps, mkbundle didn't do what I wanted it to, i.e. didn't include all the linked libraries into one file?! – tyrex Feb 09 '12 at 16:48
  • 1
    According to [this link](http://stackoverflow.com/questions/246007/how-to-determine-whether-a-given-linux-is-32-bit-or-64-bit) the server has a 32bit kernel, while I use the mkbundle-command on a 64bit kernel. May this be the problem? I edited the question accordingly. – tyrex Feb 09 '12 at 17:34

1 Answers1

7

mkbundle from 64-bit Mono generates 64-bit executables and you cannot run a 64-bit executable on 32-bit kernel. As mkbundle doesn't have an option to generate 32-bit binaries you apparently need to generate your executable with 32-bit Mono (theoretically you can install 32-bit Mono on your 64-bit system but that is not very easy so I suggest installing a 32-bit system somewhere, maybe in VM).

wRAR
  • 25,009
  • 4
  • 84
  • 97
  • Yes, basically mkbundle relies on embedding the static or shared library that makes up part of the runtime you are using. – IanNorton Feb 09 '12 at 20:48