Recent

Author Topic: Cross compilation libraries from Win32 to Linux  (Read 3213 times)

regs

  • New Member
  • *
  • Posts: 46
Cross compilation libraries from Win32 to Linux
« on: August 29, 2016, 05:11:04 am »
having error
C:\FPC\3.0.0\bin\i386-Win32\x86_64-linux-ld.exe: cannot find /lib64/ld-linux-x86-64.so.2

File is in folder with all other libraries. It's provided with -FI. Apps cross compiles well, but not libraries. Tried -Xd as suggested in some threads, but still same. Am I missing something?

Thaddy

  • Hero Member
  • *****
  • Posts: 10516
Re: Cross compilation libraries from Win32 to Linux
« Reply #1 on: August 29, 2016, 09:01:38 am »
What you are missing is that for that platform the internal linker and assembler  will just work. Don't need to specify an internal linker or assembler.
What you DO have to do is maybe set some options that are linux specific. like maybe -fPIC and -Tlinux

If you want to use un external linker anyway, the options are -FL\path\to\the\linker\ld (capital L, not lowercase l, not -Fl) , use -XP<x> for the binutilsprefix and -FD<binutils path>

regs

  • New Member
  • *
  • Posts: 46
Re: Cross compilation libraries from Win32 to Linux
« Reply #2 on: August 29, 2016, 09:14:13 am »
there is a full command line from project options. if i change library to program everything goes well.

Code: Pascal  [Select][+][-]
  1.  -Tlinux -Px86_64 -MObjFPC -Scghi -Cg -O1 -Xs -l -vewnhibq -Fis:\libtest\lib\linux-x86_64-gtk2
  2. -Flc:\fpc\3.0.0\libraries\linux\x86_64 -FuC:\lazarus-trunk\lcl\units\x86_64-linux\gtk2 -FuC:\lazarus-trunk\lcl\units\x86_64-linux
  3. -FuC:\lazarus-trunk\components\lazutils\lib\x86_64-linux -FuC:\lazarus-trunk\packager\units\x86_64-linux
  4. -Fus:\libtest\ -FUs:\libtest\lib\linux-x86_64-gtk2\ -FEs:\libtest\bin\ -olibtest.so -dLCL -dLCLgtk2




edit: this indeed did it
-FLc:\fpc\3.0.0\libraries\linux\x86_64\ld-linux-x86-64.so.2
« Last Edit: August 29, 2016, 09:23:00 am by regs »

Fr0sT-Brutal

  • Newbie
  • Posts: 2
Re: Cross compilation libraries from Win32 to Linux
« Reply #3 on: July 15, 2020, 09:21:08 am »
edit: this indeed did it
-FLc:\fpc\3.0.0\libraries\linux\x86_64\ld-linux-x86-64.so.2
Thanks man! You saved me from several hours of frustrating searches in the state of furious rage. >:(
I just wonder why the hell it was so complex to find, how the "Use <x> as dynamic linker" is related to "cannot find shared library" error and where this option in Lazarus? Had to add "-FL$(LazarusDir)\..\FPC\lib\$(TargetCPU)-$(TargetOS)\ld-linux.so.2" to Project options => Compiler options => Custom options

PascalDragon

  • Hero Member
  • *****
  • Posts: 2262
  • Compiler Developer
Re: Cross compilation libraries from Win32 to Linux
« Reply #4 on: July 15, 2020, 09:34:25 am »
What you are missing is that for that platform the internal linker and assembler  will just work. Don't need to specify an internal linker or assembler.
What you DO have to do is maybe set some options that are linux specific. like maybe -fPIC and -Tlinux

If you want to use un external linker anyway, the options are -FL\path\to\the\linker\ld (capital L, not lowercase l, not -Fl) , use -XP<x> for the binutilsprefix and -FD<binutils path>

Thaddy, that is nonsense. The internal/external linker stuff is about the static linker that the compiler uses to generate the binary. The dynamic linker is what is used by Linux when the executable is run to load libraries it is depending on. Your suggestion to pass a full Windows path using -FL is wrong and will lead to the generated binary not working on Linux if it requires external libraries. Instead the path to the root needs to be supplied using -XR\path\to\root\of\linux\binaries and the dynamic linker (ld-linux-x86-64.so.2) needs to reside in the same subdirectory that it will reside on the Linux system as well (e.g. lib\).

Thaddy

  • Hero Member
  • *****
  • Posts: 10516
Re: Cross compilation libraries from Win32 to Linux
« Reply #5 on: July 15, 2020, 10:19:18 am »
What you are missing is that for that platform the internal linker and assembler  will just work. Don't need to specify an internal linker or assembler.
What you DO have to do is maybe set some options that are linux specific. like maybe -fPIC and -Tlinux

If you want to use un external linker anyway, the options are -FL\path\to\the\linker\ld (capital L, not lowercase l, not -Fl) , use -XP<x> for the binutilsprefix and -FD<binutils path>
I never wrote that. I will change my passwords.
(can be checked by ip)

theo

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 1891
Re: Cross compilation libraries from Win32 to Linux
« Reply #6 on: July 15, 2020, 12:56:38 pm »
I never wrote that. I will change my passwords.

This post is 4 years old.
Why should someone hack your account to write this?

marcov

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 8787
  • FPC developer.
Re: Cross compilation libraries from Win32 to Linux
« Reply #7 on: July 15, 2020, 01:13:00 pm »
Moreover, there is no internal linker enabled for 64-bit Linux, even if it weren't.

 

TinyPortal © 2005-2018