linux 64bit binary?

All topics about ZGameEditor goes here.

Moderator: Moderators

User avatar
Ats
Posts: 603
Joined: Fri Sep 28, 2012 10:05 am
Contact:

Re: linux 64bit binary?

Post by Ats »

Oh, ok. So I found libc.so in /usr/lib/x86_64-linux-gnu/ but no trace of libc.dylib anywhere. In fact, there isn't a single .dylib in that folder.

So I tried compiling anyway with that:

/usr/local/lib/fpc/3.3.1/ppcx64 -al -XXis -O2 -dZZDC_SDL SDL -dMINIMAL -FU./Build/obj/ -Fu/usr/local/lib/fpc/3.3.1/units/x86_64-linux/pthreads/ -Fu/usr/local/lib/fpc/3.3.1/units/x86_64-linux/fcl-base/ -Fu/usr/local/lib/fpc/3.3.1/units/x86_64-linux/paszlib/ -Fu/usr/local/lib/fpc/3.3.1/units/x86_64-linux/hash/ -Fu/usr/local/lib/fpc/3.3.1/units/x86_64-linux/rtl-objpas/ -k-L/usr/lib/x86_64-linux-gnu/ -B -Mdelphi -FE./Build/ ZzDC.dpr

but I still get:

/usr/bin/ld: cannot find -lc.dylib
Error: Error while linking
User avatar
Ats
Posts: 603
Joined: Fri Sep 28, 2012 10:05 am
Contact:

Re: linux 64bit binary?

Post by Ats »

After a few researches, it looks like .dylib is a OSX extension for a shared library. On linux, it should search for a .so library.

So I simply replaced "dylib" per "so" in ZExpression.pas:

Line 2179:
function mprotect(__addr:pointer;__len:cardinal;__prot:longint):longint; cdecl; external 'libc.dylib' name 'mprotect';

Line 2560:
function mprotect(__addr:pointer;__len:cardinal;__prot:longint):longint; cdecl; external 'libc.dylib' name 'mprotect';
procedure pthread_jit_write_protect_np(enabled : integer); cdecl; external 'pthread.dylib' name 'pthread_jit_write_protect_np';
procedure sys_icache_invalidate(start : pointer; len : nativeuint); cdecl; external 'libc.dylib' name 'sys_icache_invalidate';

And it compiled !

I can compile ZGE project using Player_linux.bin (64) but they don't display a thing, surely because of all those lines we deactivated?

There's also a dylib that isn't hidden behind a {$IFDEF MACOS} in ZPlatform_MacZgeViz.inc, but I didn't touch it:
S:= AnsiString(ChangeFileExt(String(DesignerFilePath) + String(Name),'.dylib'));
Last edited by Ats on Tue Apr 13, 2021 11:50 am, edited 1 time in total.
User avatar
VilleK
Site Admin
Posts: 2274
Joined: Mon Jan 15, 2007 4:50 pm
Location: Stockholm, Sweden
Contact:

Re: linux 64bit binary?

Post by VilleK »

Aha, good progress. I should have known about .so files.

So it creates a window but doesn't display anything? What if you try a very simple ZGE project that does not use any external libraries?
User avatar
Ats
Posts: 603
Joined: Fri Sep 28, 2012 10:05 am
Contact:

Re: linux 64bit binary?

Post by Ats »

That's exactly what I tried: just a simple rotating cube.

For the app loading external libraries, it just crash and display the library name, the same as when I wasn't able to load it: "./sunvox_lofi.so"
User avatar
VilleK
Site Admin
Posts: 2274
Joined: Mon Jan 15, 2007 4:50 pm
Location: Stockholm, Sweden
Contact:

Re: linux 64bit binary?

Post by VilleK »

Strange. So it shows a empty black window and you can close it using Escape or mouse and it doesn't output any error information?

Do you use the very latest version of ZGE to generate the content? Please check: http://www.zgameeditor.org/files/ZGameEditor_beta.zip
User avatar
Ats
Posts: 603
Joined: Fri Sep 28, 2012 10:05 am
Contact:

Re: linux 64bit binary?

Post by Ats »

Exactly what is happening. And I'm already using the latest ZGE.

I also recompiled Player_linux.bin (64) from scratch using:

ZExpression.pas
comment line 575 about WinApi.Windows
replaced all .dylib per .so

ZPlatform_SDL.inc
replaced line 13 libc per dl
comment line 485: I := libc.system(Str) shr 8;

/usr/local/lib/fpc/3.3.1/ppcx64 -al -XXis -O2 -dZZDC_SDL SDL -dMINIMAL -FU./Build/obj/ -Fu/usr/local/lib/fpc/3.3.1/units/x86_64-linux/pthreads/ -Fu/usr/local/lib/fpc/3.3.1/units/x86_64-linux/fcl-base/ -Fu/usr/local/lib/fpc/3.3.1/units/x86_64-linux/paszlib/ -Fu/usr/local/lib/fpc/3.3.1/units/x86_64-linux/hash/ -Fu/usr/local/lib/fpc/3.3.1/units/x86_64-linux/rtl-objpas/ -Fu/usr/lib/x86_64-linux-gnu/ -B -Mdelphi -FE./Build/ ZzDC.dpr

(instead of -k-L<lib>)

I just tried launching the elf using gdb for debugging, but it is very happy with both 32 and 64bit versions of my rotating cube, even if the 64 one is an empty black void.

Here's the compilation log:

Code: Select all

Warning: Only one source file supported, changing source file to compile from "SDL" into "ZzDC.dpr"
Free Pascal Compiler version 3.3.1 [2021/04/10] for x86_64
Copyright (c) 1993-2021 by Florian Klaempfl and others
Note: Switching assembler to default source writing assembler
Target OS: Linux for x86-64
Compiling ZzDC.dpr
Compiling ZClasses.pas
ZClasses.pas(585,5) Warning: Constructor should be public
Compiling ZMath.pas
Assembling zmath
Compiling ZLog.pas
Compiling ZPlatform.pas
Compiling SDL.pas
Assembling sdl
Compiling AudioPlayer.pas
Compiling AudioComponents.pas
Compiling ZApplication.pas
Compiling Meshes.pas
Compiling ZBitmap.pas
Compiling ZOpenGL.pas
Assembling zopengl
Assembling zbitmap
Compiling ZExpressions.pas
Compiling ZApplication.pas
Compiling Meshes.pas
Compiling ZApplication.pas
Compiling Collision.pas
Compiling ZApplication.pas
Compiling Commands.pas
Compiling ZApplication.pas
Compiling GLDrivers.pas
Compiling Renderer.pas
Compiling ZApplication.pas
Compiling GLDrivers.pas
GLDrivers.pas(286,7) Warning: Case statement does not handle all possible cases
GLDrivers.pas(572,32) Warning: Conversion between ordinals and pointers is not portable
GLDrivers.pas(577,43) Warning: Conversion between ordinals and pointers is not portable
GLDrivers.pas(586,40) Warning: Conversion between ordinals and pointers is not portable
GLDrivers.pas(950,54) Warning: Conversion between ordinals and pointers is not portable
GLDrivers.pas(956,63) Warning: Conversion between ordinals and pointers is not portable
GLDrivers.pas(963,56) Warning: Conversion between ordinals and pointers is not portable
Assembling gldrivers
ZApplication.pas(613,5) Warning: Case statement does not handle all possible cases
ZApplication.pas(1112,8) Warning: Conversion between ordinals and pointers is not portable
Assembling zapplication
Renderer.pas(804,17) Warning: Converting pointers to signed integers may result in wrong comparison results and range errors, use an unsigned type instead.
Renderer.pas(1288,18) Warning: Local variable "Lists" does not seem to be initialized
Renderer.pas(1465,20) Warning: Converting pointers to signed integers may result in wrong comparison results and range errors, use an unsigned type instead.
Renderer.pas(1466,20) Warning: Converting pointers to signed integers may result in wrong comparison results and range errors, use an unsigned type instead.
Renderer.pas(1916,5) Warning: Case statement does not handle all possible cases
Assembling renderer
Assembling commands
Collision.pas(471,3) Warning: Case statement does not handle all possible cases
Assembling collision
Assembling meshes
ZExpressions.pas(672,3) Note: Local variable "NilP" is assigned but never used
ZExpressions.pas(731,3) Warning: Case statement does not handle all possible cases
ZExpressions.pas(832,9) Note: Local variable "V" is assigned but never used
ZExpressions.pas(850,9) Note: Local variable "V" is assigned but never used
ZExpressions.pas(902,13) Warning: Case statement does not handle all possible cases
ZExpressions.pas(916,13) Warning: Case statement does not handle all possible cases
ZExpressions.pas(1443,3) Note: Local variable "P" is assigned but never used
ZExpressions.pas(1555,3) Note: Local variable "RetVal" is assigned but never used
ZExpressions.pas(1819,3) Note: Local variable "V" is assigned but never used
ZExpressions.pas(1960,3) Warning: Case statement does not handle all possible cases
ZExpressions.pas(2264,3) Note: Local variable "OldProtect" not used
ZExpressions.pas(2834,3) Note: Local variable "C" is assigned but never used
ZExpressions.pas(2899,5) Warning: Case statement does not handle all possible cases
ZExpressions.pas(2964,3) Warning: Case statement does not handle all possible cases
Assembling zexpressions
Compiling BeRoAudioOGGVorbisTremor.pas
Assembling beroaudiooggvorbistremor
Assembling audiocomponents
AudioPlayer.pas(250,5) Warning: Case statement does not handle all possible cases
AudioPlayer.pas(397,22) Warning: Unreachable code
AudioPlayer.pas(431,19) Warning: Unreachable code
AudioPlayer.pas(1036,17) Warning: Unreachable code
Assembling audioplayer
Assembling zplatform
Assembling zlog
ZClasses.pas(731,5) Warning: Constructor should be public
ZClasses.pas(802,6) Warning: Converting pointers to signed integers may result in wrong comparison results and range errors, use an unsigned type instead.
ZClasses.pas(803,14) Warning: Converting pointers to signed integers may result in wrong comparison results and range errors, use an unsigned type instead.
ZClasses.pas(1116,5) Warning: Case statement does not handle all possible cases
ZClasses.pas(1169,5) Warning: Case statement does not handle all possible cases
ZClasses.pas(1259,38) Warning: Unreachable code
ZClasses.pas(1329,38) Warning: Unreachable code
ZClasses.pas(1348,23) Warning: Converting pointers to signed integers may result in wrong comparison results and range errors, use an unsigned type instead.
ZClasses.pas(1383,5) Warning: Case statement does not handle all possible cases
ZClasses.pas(1532,5) Warning: Case statement does not handle all possible cases
ZClasses.pas(2162,15) Warning: Converting pointers to signed integers may result in wrong comparison results and range errors, use an unsigned type instead.
ZClasses.pas(2955,5) Warning: Case statement does not handle all possible cases
ZClasses.pas(3032,5) Warning: Case statement does not handle all possible cases
ZClasses.pas(3079,14) Warning: Conversion between ordinals and pointers is not portable
ZClasses.pas(4012,19) Warning: Converting pointers to signed integers may result in wrong comparison results and range errors, use an unsigned type instead.
ZClasses.pas(4012,38) Warning: Converting pointers to signed integers may result in wrong comparison results and range errors, use an unsigned type instead.
Assembling zclasses
Compiling BitmapProducers.pas
Compiling NanoJpeg.pas
Assembling nanojpeg
BitmapProducers.pas(548,9) Warning: Case statement does not handle all possible cases
Assembling bitmapproducers
Compiling Animators.pas
Assembling animators
Compiling Steering.pas
Assembling steering
Compiling ImplicitMeshes.pas
ImplicitMeshes.pas(196,5) Warning: Constructor should be public
Assembling implicitmeshes
Compiling ZFile.pas
ZFile.pas(337,3) Warning: Case statement does not handle all possible cases
Assembling zfile
Assembling zzdc
Linking ./Build/ZzDC
43054 lines compiled, 1.9 sec, 392848 bytes code, 245409 bytes data
46 warning(s) issued
9 note(s) issued
User avatar
VilleK
Site Admin
Posts: 2274
Joined: Mon Jan 15, 2007 4:50 pm
Location: Stockholm, Sweden
Contact:

Re: linux 64bit binary?

Post by VilleK »

Just so I understand the whole workflow here:

Do you rename the binary to "player_linux.bin" and then use "Project - Build Linux Binary" in ZGE to generate final binary?

What if you try even simpler project where you just set the background color (App.ClearColor) to red, does this work?
User avatar
Ats
Posts: 603
Joined: Fri Sep 28, 2012 10:05 am
Contact:

Re: linux 64bit binary?

Post by Ats »

Still exactly what I'm doing :)

App.ClearColor is working, but no cube is showing on the cube64 test.

Here's the ZGE cube code:

Code: Select all

<?xml version="1.0" encoding="iso-8859-1" ?>
<ZApplication Name="App" Caption="simple cube" ClearColor="1 0.502 0.7529 1" FileVersion="2" AndroidPackageName="com.mydomain.cube">
  <OnLoaded>
    <SpawnModel Model="Model1"/>
  </OnLoaded>
  <Content>
    <Mesh Name="Mesh1">
      <Producers>
        <MeshBox/>
      </Producers>
    </Mesh>
    <Model Name="Model1">
      <OnSpawn>
        <ZExpression>
          <Expression>
<![CDATA[CurrentModel.RotationVelocity.X=.1;
CurrentModel.RotationVelocity.Y=.1;
CurrentModel.RotationVelocity.Z=.1;]]>
          </Expression>
        </ZExpression>
      </OnSpawn>
      <OnRender>
        <RenderMesh Mesh="Mesh1"/>
      </OnRender>
    </Model>
  </Content>
</ZApplication>
Also, I made you a zip with both Player_linux.bin 32 and 64, just rename the one you want to use.
And the cube32 and cube64 tests.
Attachments
player_linux_32_64.zip
(927.38 KiB) Downloaded 223 times
User avatar
VilleK
Site Admin
Posts: 2274
Joined: Mon Jan 15, 2007 4:50 pm
Location: Stockholm, Sweden
Contact:

Re: linux 64bit binary?

Post by VilleK »

I don't have a Linux system to try on. I only have Mac and Windows here.

I'm out of ideas at the moment. If you have time then please try some more simple projects and tell me what works and doesn't. Does audio work? Does RenderSprite work? Things like that. Then maybe that can provide some clues what is wrong.
User avatar
Ats
Posts: 603
Joined: Fri Sep 28, 2012 10:05 am
Contact:

Re: linux 64bit binary?

Post by Ats »

First I tried adding App.ClearColor.A=1; on my simple cube test, same as for Android, without results.

The i tried some examples from ZGameEditor/Projects :

About
RenderText and RenderMesh does not work.

Audio
It displays an error and quit with "only 16 bit audio supported". But I have the same problem with 32bit. So it must be another bug.

CollisionTests
I added App.ClearColor.R=1; for when the collision occurs, but it isn't happening on 64bit. So maybe it's not a rendering problem?

TestBars
I get an error in 32 and 64bit:

Code: Select all

[code]An unhandled exception occurred at $000000000043CED0:
ESyncObjectException: Failed to create OS basic event with name ""
  $000000000043CED0

Then I made another test with my SunVox test and a music file that works:
Player_linux.bin 32 + sunvox.so 32 = it's working
Player_linux.bin 64 + sunvox.so 32 = it crashes and displays "./sunvox.so" as if it wasn't able to find it, weird... Maybe because it's lib 32?
Player_linux.bin 64 + sunvox.so 64 = it launches but with some errors: Wrong slot number -361436736! Correct values: 0...15
And that number is random each time I launch the test.


Then I made a very simple test: Combine App.ClearColor and KeyPress Component: it's working.

Code: Select all

<?xml version="1.0" encoding="iso-8859-1" ?>
<ZApplication Name="App" Caption="ZGameEditor application" FileVersion="2">
  <OnUpdate>
    <ZExpression Expression="App.ClearColor.R = 0;"/>
    <KeyPress CharCode="32">
      <OnPressed>
        <ZExpression Expression="App.ClearColor.R = 1;"/>
      </OnPressed>
    </KeyPress>
  </OnUpdate>
</ZApplication>
I added a simple RenderMesh and RenderSprite on update, but it doesn't show up. Only the blinking background with the space bar...

Do you have any other interesting tests that I could do?
Last edited by Ats on Thu Apr 15, 2021 5:06 pm, edited 1 time in total.
User avatar
VilleK
Site Admin
Posts: 2274
Joined: Mon Jan 15, 2007 4:50 pm
Location: Stockholm, Sweden
Contact:

Re: linux 64bit binary?

Post by VilleK »

I committed some changes to make the SDL support up to date for Windows, and also included the other changes you discovered so far.

Please try TestBars and Audio projects again.
User avatar
Ats
Posts: 603
Joined: Fri Sep 28, 2012 10:05 am
Contact:

Re: linux 64bit binary?

Post by Ats »

New checkout:
Still had to deactivate //{$if (not defined(minimal)) or (defined(cpux64))}, WinApi.Windows{$ifend}; which gives error.
Otherwise, everything went fine. The new Player_linux.bin build is lighter: 564Kb instead of 570Kb

Now Audio is working fine, but the little cube won't show up. GenMusic too!

TestBars isn't crashing anymore, but won't display a thing.

It's getting better :D
User avatar
Ats
Posts: 603
Joined: Fri Sep 28, 2012 10:05 am
Contact:

Re: linux 64bit binary?

Post by Ats »

Thanks to your changes with SDL2, the bin file for linux x86_64 is working perfectly :wink:
User avatar
Ats
Posts: 603
Joined: Fri Sep 28, 2012 10:05 am
Contact:

Re: linux 64bit binary?

Post by Ats »

And now I'm running tests to see if everything is working on Linux 64.


:arrow: For starters, simple RenderText doesn't show on linux. I think I saw that written somewhere for Android, but I didn't manage to find it.


[SOLVED]
:arrow: Jasper is crashing:
Loading rom...
done
Loading game...
done
An unhandled exception occurred at $0000000000416ECB:
EAccessViolation: Access violation
$0000000000416ECB


:arrow: Then I started Omeganaut...
My own var Viewport doesn't seem to be initialized with:
glGetIntegerc(0x0BA2, Viewport);
ScreenWidth = Viewport[2];
ScreenHeight = Viewport[3];
Maybe that's the same as Android?

[SOLVED]
The arrow keys are not working. I'm going to make a simple test to display ascii key codes.

[SOLVED]
Oh, and one more surprise, Omeganaut don't work on Windows. It displays the name of the sunvox music in an error window, as if it couldn't be found in the File/FileEmbedded component. But I will run simple tests too.

[SOLVED]
:arrow: I modified ZPong to play with the keyboard. Arrows aren't detected on linux, even though it's the same KeyCodes: https://keycode.info/
Then I tried the same keys with KeyPress/Keys <> and it's crashing the same way as Jasper:
An unhandled exception occurred at $0000000000416ECB:
EAccessViolation: Access violation
$0000000000416ECB
Last edited by Ats on Fri Apr 23, 2021 11:14 am, edited 3 times in total.
User avatar
Kjell
Posts: 1876
Joined: Sat Feb 23, 2008 11:15 pm

Re: linux 64bit binary?

Post by Kjell »

Hi Ats,
Ats wrote: Thu Apr 22, 2021 4:11 pmFor starters, simple RenderText doesn't show on linux. I think I saw that written somewhere for Android, but I didn't manage to find it.
Did you use your own Font component? The built-in font only works on Windows ( here is the Linux implementation :wink: ).
Ats wrote: Thu Apr 22, 2021 4:11 pmArrows aren't detected on linux, even though it's the same KeyCodes
The SDL keycodes aren't identical to the native Linux keycodes.

K
Post Reply