alliedmodders / amxmodx

AMX Mod X - Half-Life 1 Scripting and Administration
http://www.amxmodx.org/
499 stars 203 forks source link

Cannot run ./amxxpc on Ubuntu 18.04 on Windows 10 #1011

Closed bigdaddy424 closed 3 years ago

bigdaddy424 commented 3 years ago

I cannot run ./amxxpc on Ubuntu 18.04 on Windows 10. I'm using a 64bit cpu. I've also install added architecture i386 but still not working. Can I compile the compiler myself so it can be 64bit? If so how do I compile it. Thanks

file amxxpc
amxxpc: ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), dynamically linked, interpreter /lib/ld-linux.so.2, for GNU/Linux 2.6.32, BuildID[sha1]=fd5147055fad05f17f528a9ec7a9131b7e779785, not stripped 

file amxxpc32.so
amxxpc32.so: ELF 32-bit LSB shared object, Intel 80386, version 1 (SYSV), dynamically linked, BuildID[sha1]=f6b7780055b7c367e390ac977ea272b586da04d8, not stripped `

neofetch
OS: Ubuntu 18.04.6 LTS on Windows 10 x86_64
Kernel: 4.4.0-19041-Microsoft
ShootingKing-AM commented 3 years ago

I cannot run ./amxxpc on Ubuntu 18.04 on Windows 10. I'm using a 64bit cpu. I've also install added architecture i386 but still not working. Can I compile the compiler myself so it can be 64bit? If so how do I compile it. Thanks

file amxxpc
amxxpc: ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), dynamically linked, interpreter /lib/ld-linux.so.2, for GNU/Linux 2.6.32, BuildID[sha1]=fd5147055fad05f17f528a9ec7a9131b7e779785, not stripped 

file amxxpc32.so
amxxpc32.so: ELF 32-bit LSB shared object, Intel 80386, version 1 (SYSV), dynamically linked, BuildID[sha1]=f6b7780055b7c367e390ac977ea272b586da04d8, not stripped `

neofetch
OS: Ubuntu 18.04.6 LTS on Windows 10 x86_64
Kernel: 4.4.0-19041-Microsoft

What's the issue ? What happens when you ./amxxpc

dvander commented 3 years ago

64-bit builds of amxmodx are not supported, and will likely not produce working .amxx files.

You can use ldd to see what's missing, or you can build the compiler in 32-bit mode. Instructions are here: https://wiki.alliedmods.net/Building_AMX_Mod_X

You will need some 32-bit dependencies:

sudo apt-get install clang lib32stdc++-7-dev lib32z1-dev libc6-dev-i386 linux-libc-dev:i386
sudo apt-get install g++-multilib
bigdaddy424 commented 3 years ago

@ShootingKing-AM I get this ./amxxpc: cannot execute binary file: Exec format error @dvander It did install around 300MBs of packages but it doesn't seem to work whatsoever. I might try building it myself and update you back.

ShootingKing-AM commented 3 years ago

I am hoping you are using wsl2, and official snapshot. Which version and build of amxmodx are you using ? Where did you get the amxmodx from ?

dvander commented 3 years ago

The docs might be missing some, or the packages needed may change over time. Anyway, some backstory:

Many, many years ago (2003-4?) Valve did a half-hearted attempt at 64-bit support for GoldSrc. They almost immediately abandoned it. Nonetheless, we put a lot of effort into supporting it when it came out. Anyway... the original Pawn is designed to load plugin files directly into memory as pseudo-executables. There is no translation phase like SourcePawn has. And this means, a lot of stuff in the VM (and file-format) makes the assumption that the cell size is equal to the machine word size.

As a result, we made amxxpc a "wrapper" that had two builds of the compiler (one with cell size set to 32, and another with cell size set to 64). It then packaged both .amx files into a fat .amxx bundle. Nowadays, we no longer generate 64-bit plugins. And AMX Mod X will refuse to load 32-bit plugins on a 64-bit build, or vice-versa.

Why do I bring this all up? Because if you build a 64-bit compiler, you will need to make sure the cell size is forced to 32, so the "fat" binary loads. That likely requires code changes.

Of course, it's way easier to just find the packages that get your distro working.

bigdaddy424 commented 3 years ago

@ShootingKing-AM I'm using the one from Microsoft Store and the latest MASTER-BRANCH base and cstrike package combined. @dvander checkout-deps.sh had everything I needed. However it still failed

[7274] ./amxxpc -i../includes -i../../plugins/include -h -E /root/amxx/amxmodx/plugins/cstrike/restmenu.sma -ocstrike/restmenu.amxx
Traceback (most recent call last):
  File "/usr/local/lib/python2.7/dist-packages/AMBuild-2.0-py2.7.egg/ambuild2/task.py", line 85, in receive_task
    return self.process_task(channel, message)
  File "/usr/local/lib/python2.7/dist-packages/AMBuild-2.0-py2.7.egg/ambuild2/task.py", line 120, in process_task
    response = self.taskMap[task_type](message)
  File "/usr/local/lib/python2.7/dist-packages/AMBuild-2.0-py2.7.egg/ambuild2/task.py", line 70, in <lambda>
    'cxx': lambda message: self.doCompile(message),
  File "/usr/local/lib/python2.7/dist-packages/AMBuild-2.0-py2.7.egg/ambuild2/task.py", line 278, in doCompile
    p, out, err = util.Execute(argv, env = env)
  File "/usr/local/lib/python2.7/dist-packages/AMBuild-2.0-py2.7.egg/ambuild2/util.py", line 269, in Execute
    env = env)
  File "/usr/lib/python2.7/subprocess.py", line 394, in __init__
    errread, errwrite)
  File "/usr/lib/python2.7/subprocess.py", line 1047, in _execute_child
    raise child_exception
OSError: [Errno 8] Exec format error
Build failed: plugins/cstrike/restmenu.amxx

I ran the compiler on the windows version and it compiled with no errors tho. Will there ever be a 64bit compiler for the linux community? Or there is one but it's just me that can't get it to work.

bigdaddy424 commented 3 years ago

Both amxxpc and amxxpc32.so made their way on the build folder at build/compiler but they still wont execute.

ShootingKing-AM commented 3 years ago

@ShootingKing-AM I'm using the one from Microsoft Store and the latest MASTER-BRANCH base and cstrike package combined. @dvander checkout-deps.sh had everything I needed. However it still failed

[7274] ./amxxpc -i../includes -i../../plugins/include -h -E /root/amxx/amxmodx/plugins/cstrike/restmenu.sma -ocstrike/restmenu.amxx
Traceback (most recent call last):
  File "/usr/local/lib/python2.7/dist-packages/AMBuild-2.0-py2.7.egg/ambuild2/task.py", line 85, in receive_task
    return self.process_task(channel, message)
  File "/usr/local/lib/python2.7/dist-packages/AMBuild-2.0-py2.7.egg/ambuild2/task.py", line 120, in process_task
    response = self.taskMap[task_type](message)
  File "/usr/local/lib/python2.7/dist-packages/AMBuild-2.0-py2.7.egg/ambuild2/task.py", line 70, in <lambda>
    'cxx': lambda message: self.doCompile(message),
  File "/usr/local/lib/python2.7/dist-packages/AMBuild-2.0-py2.7.egg/ambuild2/task.py", line 278, in doCompile
    p, out, err = util.Execute(argv, env = env)
  File "/usr/local/lib/python2.7/dist-packages/AMBuild-2.0-py2.7.egg/ambuild2/util.py", line 269, in Execute
    env = env)
  File "/usr/lib/python2.7/subprocess.py", line 394, in __init__
    errread, errwrite)
  File "/usr/lib/python2.7/subprocess.py", line 1047, in _execute_child
    raise child_exception
OSError: [Errno 8] Exec format error
Build failed: plugins/cstrike/restmenu.amxx

I ran the compiler on the windows version and it compiled with no errors tho. Will there ever be a 64bit compiler for the linux community? Or there is one but it's just me that can't get it to work.

Wsl2 is, imo, still underdevelopment, so it's not exactly how proper linux functions. I strongly feel it's wsl's failure. You can try wsl1 to see if that does the job.

That being said you should use a proper virtual machine like virtual box or similar Instead of subsystem.

And I think, without the base engine being in 64bit, it just too much init work and maintenance to support 64bit + little performance gain.

bigdaddy424 commented 3 years ago

The first answer on https://stackoverflow.com/questions/42120938/exec-format-error-32-bit-executable-windows-subsystem-for-linux solved my question. Also thank you guys both for helping.

dvander commented 3 years ago

Glad to hear you got it working. FWIW I use WSL2 for almost all my Linux development. It works remarkably well.