Page 3 of 4

Re:

Posted: Sat Apr 10, 2021 11:54 am
by Ats
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

Re: Re:

Posted: Sat Apr 10, 2021 1:09 pm
by VilleK
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.

Re: linux 64bit binnary?

Posted: Sat Apr 10, 2021 1:17 pm
by Ats
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.

linux 64bit binnary?

Posted: Sat Apr 10, 2021 2:17 pm
by Ats
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.

Re: linux 64bit binnary?

Posted: Sat Apr 10, 2021 3:16 pm
by VilleK
Where does it stop if you remove "libc" from the uses list? Try using "dl" instead.

Re: linux 64bit binnary?

Posted: Sat Apr 10, 2021 3:51 pm
by Ats
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?

Re: linux 64bit binnary?

Posted: Sat Apr 10, 2021 4:55 pm
by VilleK
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};

Re: linux 64bit binnary?

Posted: Sat Apr 10, 2021 5:07 pm
by Ats
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

Re: linux 64bit binnary?

Posted: Mon Apr 12, 2021 8:08 am
by VilleK
Ok then try removing ", WinApi.Windows" completely just to see where it stops next.

Re: linux 64bit binnary?

Posted: Mon Apr 12, 2021 11:53 am
by Ats
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

Re: linux 64bit binnary?

Posted: Mon Apr 12, 2021 1:16 pm
by VilleK
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.

Re: linux 64bit binnary?

Posted: Mon Apr 12, 2021 1:41 pm
by Ats
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';

Re: linux 64bit binnary?

Posted: Mon Apr 12, 2021 2:18 pm
by VilleK
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.

Re: linux 64bit binnary?

Posted: Mon Apr 12, 2021 2:45 pm
by Ats
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:

Re: linux 64bit binnary?

Posted: Tue Apr 13, 2021 6:51 am
by VilleK
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?