linux 64bit binary?

All topics about ZGameEditor goes here.

Moderator: Moderators

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

Re:

Post by Ats » Sat Apr 10, 2021 11:54 am

By the way, the tests I'm currently running on linux gave me that problem on my Linux 64 computer:
Imerion wrote:
Wed Apr 23, 2014 9:58 am
I finally came long enough to try running my game in Linux using this binary.
All I get is this message though : "OpenGL could not be loaded".
How come? OpenGL works fine in all other programs, including a bunch of modern games. I run Xubuntu 14.04 and have an Intel HD4400 graphics card with the latest drivers and mesa 10.1.
ZGE is looking for libGL.so in the i386 lib folder. So I managed to make it work by creating a symlink using:

Code: Select all

sudo ln -s /usr/lib/i386-linux-gnu/libGL.so.1.7.0 /usr/lib/i386-linux-gnu/libGL.so

User avatar
VilleK
Site Admin
Posts: 2151
Joined: Mon Jan 15, 2007 4:50 pm
Location: Stockholm, Sweden
Contact:

Re: Re:

Post by VilleK » Sat Apr 10, 2021 1:09 pm

Ats wrote:
Sat Apr 10, 2021 11:54 am
ZGE is looking for libGL.so in the i386 lib folder. So I managed to make it work by creating a symlink using:

Code: Select all

sudo ln -s /usr/lib/i386-linux-gnu/libGL.so.1.7.0 /usr/lib/i386-linux-gnu/libGL.so
I see. I don't remember the whole history of this thread but did you get ZGE built for Linux 64-bit successfully at some point? Might be a better idea than to get 32-bit working.

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

Re: linux 64bit binnary?

Post by Ats » Sat Apr 10, 2021 1:17 pm

I was currently trying to compile ZgeBullet for linux, but I don't understand everything yet. So I'm going to try compiling ZGE for linux 64. I don't remember why it didn't work last time I tried. I'll keep you updated.

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

linux 64bit binnary?

Post by Ats » Sat Apr 10, 2021 2:17 pm

And I'm stuck with the same problem I had in 2014 (time flies...), there is no libc folder in the latest fpc subversion fpc/3.3.1/units/x86_64-linux folder. It only exists for i386 and I had a few warnings about that outdated lib on the other computer.

Could you do that change you mentioned back then?
VilleK wrote:
Mon Feb 24, 2014 8:23 am
It shouldn't have to be this difficult. But maybe they've actually removed Libc from the Freepascal distribution. In that case I should try to look for alternatives because platform_sdl only uses a few calls from Libc, they could be declared internally instead.

User avatar
VilleK
Site Admin
Posts: 2151
Joined: Mon Jan 15, 2007 4:50 pm
Location: Stockholm, Sweden
Contact:

Re: linux 64bit binnary?

Post by VilleK » Sat Apr 10, 2021 3:16 pm

Where does it stop if you remove "libc" from the uses list? Try using "dl" instead.

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

Re: linux 64bit binnary?

Post by Ats » Sat Apr 10, 2021 3:51 pm

It stops at ZExpressions.pas(575,52) Fatal: Can't find unit WinApi.Windows used by ZExpressions

I don't understand what you mean by using "dl" instead. There is no dl folder either in units/x86_64-linux/, or is it a argument to compile with ppcx64?

User avatar
VilleK
Site Admin
Posts: 2151
Joined: Mon Jan 15, 2007 4:50 pm
Location: Stockholm, Sweden
Contact:

Re: linux 64bit binnary?

Post by VilleK » Sat Apr 10, 2021 4:55 pm

Ok good then it seems libc is not used.

Try to change the ZExpression.pas line 575 like this:

{$if defined(mswindows) and (not defined(minimal)) or (defined(cpux64))}, WinApi.Windows{$ifend};

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

Re: linux 64bit binnary?

Post by Ats » Sat Apr 10, 2021 5:07 pm

It just moved the problem a few chars to the right :(
ZExpressions.pas(575,75) Fatal: Can't find unit WinApi.Windows used by ZExpressions

User avatar
VilleK
Site Admin
Posts: 2151
Joined: Mon Jan 15, 2007 4:50 pm
Location: Stockholm, Sweden
Contact:

Re: linux 64bit binnary?

Post by VilleK » Mon Apr 12, 2021 8:08 am

Ok then try removing ", WinApi.Windows" completely just to see where it stops next.

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

Re: linux 64bit binnary?

Post by Ats » Mon Apr 12, 2021 11:53 am

For our next stop, libc is back again:
ZPlatform_SDL.inc(13,18) Fatal: Can't find unit libc used by ZPlatform
ZPlatform_SDL.inc(485,8) Error: Identifier not found "libc"

Searching for "dl" I thought that you were maybe talking about libdl:
ldconfig -p | grep libdl

So I replaced libc per libdl in ZPlatform_SDL.inc and tried adding it to the needed libraries at compilation:
-Fu/usr/lib/x86_64-linux-gnu/
and also
-Fu/lib/x86_64-linux-gnu/
as /usr/lib/x86_64-linux-gnu/libdl.so redirects to /lib/x86_64-linux-gnu/libdl.so.2 which redirects to /lib/x86_64-linux-gnu/libdl-2.31.so ...

But I still get:
ZPlatform_SDL.inc(13,18) Fatal: Can't find unit libdl used by ZPlatform

I'm currently reading that: https://wiki.freepascal.org/libc_unit

User avatar
VilleK
Site Admin
Posts: 2151
Joined: Mon Jan 15, 2007 4:50 pm
Location: Stockholm, Sweden
Contact:

Re: linux 64bit binnary?

Post by VilleK » Mon Apr 12, 2021 1:16 pm

Try commenting out or deleting this line (ZPlatform_SDL.inc line 485):

I := libc.system(Str) shr 8;

Then replace "libc" with "dl" in the uses list. Does it not find unit "dl"? It should exist in Freepascal for Linux.

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

Re: linux 64bit binnary?

Post by Ats » Mon Apr 12, 2021 1:41 pm

It goes almost to the end:

Linking ./Build/ZzDC
/usr/bin/ld: cannot find -lc.dylib
Error: Error while linking

libc.dylib is called a few times in ZExpressions.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';
line 2563: procedure sys_icache_invalidate(start : pointer; len : nativeuint); cdecl; external 'libc.dylib' name 'sys_icache_invalidate';
Last edited by Ats on Mon Apr 12, 2021 3:03 pm, edited 1 time in total.

User avatar
VilleK
Site Admin
Posts: 2151
Joined: Mon Jan 15, 2007 4:50 pm
Location: Stockholm, Sweden
Contact:

Re: linux 64bit binnary?

Post by VilleK » Mon Apr 12, 2021 2:18 pm

It seems the linker cannot find the libraries. Maybe this is because you are using a 32-bit compiler on a 64-bit host to cross compile to 64-bit.

Try add "-k-Lsomepath" when calling freepascal, where "somepath" is the path you mentioned earlier where the 32-bit libraries are located.

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

Re: linux 64bit binnary?

Post by Ats » Mon Apr 12, 2021 2:45 pm

I am compiling using ppcx64. It's the only elf available after compiling fpc 3.3.1:

/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/ -B -Mdelphi -FE./Build/ ZzDC.dpr

Then I'm not sure about your last response, isn't libc.dylib part of the libc I'm trying to get rid of because it isn't included in the latest fpc subversion fpc/3.3.1/units/x86_64-linux ? What 32-bit libraries are you refering to ? (I've just read the whole thread :?)


Edit:
/usr/bin/ld is present on my computer and redirects to /usr/bin/x86_64-linux-gnu-ld
the path you mentioned earlier where the 32-bit libraries are located.
Are you talking about the libc folder? It's on the other computer, the i386 one.


Edit 2:
Ok I get it, licc isn't -lc
usr/bin/ld: cannot find -l<nameOfTheLibrary>

But there's no "c" file. I only have a "cc" and "c++" if that's even related :roll:

User avatar
VilleK
Site Admin
Posts: 2151
Joined: Mon Jan 15, 2007 4:50 pm
Location: Stockholm, Sweden
Contact:

Re: linux 64bit binnary?

Post by VilleK » Tue Apr 13, 2021 6:51 am

libc is the standard Linux/Unix C-runtime support library. The linker needs to find it because even if we don't use the "libc.pp" unit in Freepascal, we do use it via "external" declarations (the mprotect-call).

If you search for "libc.dylib" or "libc.so" on your computer, do you find it somewhere?

Post Reply