Link Linux compiled-programs ?

Hello.

In a multi-arch FreeBSD 10.3 system, with Linux-emulator installed, I can run 64/32 Linux applications. One of them is fpc(1) (free pascal compiler).

fpc-FreeBSD-64, fpc-FreeBSD-32, fpc-Linux-64 and fpc-Windows-32 (via wine) are all working and can compile ok. fpc-FreeBSD-64, fpc-FreeBSD-32 and fpc-Windows-32 can also link the objects created. And all are perfectly running on FreeBSD 10.3 multi-arch. But for fpc-Linux-64 the link fail.

How to make ld link Linux applications too ?

Here the message given by the fpc compiler:

When compiling on a FreeBSD 64 bit system using fpc-freebsd-32 there is that message on linking:
Code:
[3.069] Searching file /usr/bin/ld... found 
[3.069] Using util /usr/bin/ld 
[3.069] Executing "/usr/bin/ld -b elf32-i386-freebsd -m elf32-i386-freebsd -L. -o ./test ./link.res" [B]with fpSystem call[/B]
[3.960] 62 lines compiled, 4.0 sec 
[3.972] 2 hint(s) issued
OK, it works.

But when compiling on a FreeBSD 64 bit system using fpc-linux-64, there is that message on linking:
(/lib64/ld-linux-x86-64.so is installed in /compat/linux/lib64)
Code:
[4.438] Searching file /bin/ld... found 
[4.438] Using util /bin/ld 
[4.438] Executing "/bin/ld" with command line "-b elf64-x86-64 -m elf_x86_64  [B]--dynamic-linker=/lib64/ld-linux-x86-64.so 
.2[/B]  -L. -o ./test ./link.res" 
/bin/ld: warning: ./link.res contains output sections; did you forget -T? 
[246.930] test.pas(62,1) Error: Can't call the linker, switching to external linking 
[246.930] test.pas(62,1) Error: Error while linking 
[246.930] test.pas(62,1) Fatal: There were 2 errors compiling module, stopping 
[247.070] Fatal: Compilation aborted
Any idea or suggestions?

Many thanks.

Fre;D
 
Last edited by a moderator:
Sorry, I don't know if the problem in the other thread is related.
"linuxolator" is a nickname for the linux kernel module in FreeBSD, also known as linux-emulator. It is updated as part of the FreeBSD base system.
 
Outside of security and errata fixes you don't update it, that's the short answer. The base system is supposed to be static in a sense that the public API/ABI provided by a particular version of FreeBSD never changes until the next higher major version comes out.

I'm pretty sure that we don't have Linux cross compilers and linkers in the ports that could accomplish what you want unless you build them yourself. One possible way would be to set up a Linux jail with a full Linux system running on top of the Linuxator and with the usual compilers and utilities that are used for compiling and linking programs on Linux. Or just install a real Linux in a VirtualBox VM and do your compilations there, should be much easier.
 
I can remember there used to be linux_base-*-devel (or something like it) ports, specifically for creating a cross-compile environment. Not sure why they've been removed. Probably because nobody maintained them.
 
Outside of security and errata fixes you don't update it, that's the short answer. The base system is supposed to be static in a sense that the public API/ABI provided by a particular version of FreeBSD never changes until the next higher major version comes out.

I'm pretty sure that we don't have Linux cross compilers and linkers in the ports that could accomplish what you want unless you build them yourself. One possible way would be to set up a Linux jail with a full Linux system running on top of the Linuxator and with the usual compilers and utilities that are used for compiling and linking programs on Linux. Or just install a real Linux in a VirtualBox VM and do your compilations there, should be much easier.

Hello kpa.

OK, it does not exist (till now) a working-linker for the Linuxator so it is a good challenge to make it.
Note that the compilation is working perfectly, all the *.o are created and I have test to link it on a Linux machine and it works.

I will try to make ld-linux work on FreeBSD.

PS: Of course a VM could make the work but it is less WoW and needs much more ressource on the machine.
PS2: To resume, I am able to cross-compile on a FreeBSD 64:
- FreeBSD 32
- Windows 32

There is only missing
- Windows 64 (I was thinking that new port has wine64 but did not find it).
- Linux 63+32 -> The challenge.

Many thanks for your precious notes.

Write you later.

I can remember there used to be linux_base-*-devel (or something like it) ports,

Ha, a good way to begin the challenge.
I will check that, many thanks.
PS: Updating did not hep.

Fre;D
 
I can remember there used to be linux_base-*-devel (or something like it) ports, specifically for creating a cross-compile environment. Not sure why they've been removed. Probably because nobody maintained them.
Hello.

I have installed linux-base-f10 + linux-f10-devtools ---> ld does not work ;-(
Then tried with linux-base-c6 + linux-c6-devtools ---> ld does not work too ;-(

But the most difficult to understand is that for both distributions, the Linuxator can only run 64 bit applications (and in doc, it is said that it can run only 32 bit applications !)

Any idea or new way is extremely welcome.

Fre;D
 
Yep, it works. :)

$ uname -a
----> FreeBSD 10.3-RELEASE #0 amd64

$ /usr/local/lib/fpc/3.0.0/ppcx64_linux test.pas
--->
Free Pascal Compiler version 3.0.0 [2015/11/20] for x86_64
Copyright (c) 1993-2015 by Florian Klaempfl and others
(1002) Target OS: Linux for x86-64
(3104) Compiling /usr/local/share/ideu/prj_test/test.pas
...
(9015) Linking ./test
/usr/bin/ld: warning: ./link.res contains output sections; did you forget -T?
(1008) 53964 lines compiled, 9.8 sec
(1021) 51 warning(s) issued
(1022) 319 hint(s) issued
(1023) 32 note(s) issued

---> Tested that X graphic application on a Linux 64 bit and it works. ;-)

Now, last thing, is to make that Linux graphic application run by the FreeBSD system (because it fails to run.)
But that is a other story.

To resume:

On a FreeBSD 64 bit system, you may, thanks to fpc, without virtual machine:
- Compile and run 64 bit FreeBSD applications.
- Compile and run 32 bit FreeBSD applications.
- Compile and run 32 bit Windows applications.
- Compile (and run) 64 bit Linux applications.

Sure that with some more white nights you could:
- Compile and run 64 bit Windows applications.
- Compile and run 32 bit Linux applications.

PS: Hum, if you want a how-to-compile-linux-apps-with-FreeBSD, I will do it with pleasure. (but lot of things must be updated in Linux-devtools package to make it work).

Fre;D
 
Hello.

Here how to make ld (binutils-linker Linux 64 bit) work:

-1) Install Linux-base package (I use linux_base-f10-10_10.txz).

-2) Download https://sites.google.com/site/fredvsbinaries/ld_compat_linux64.tar.xz.
This package include last ld and all needed libraries for linking and running Linux 64 Xorg applications on a FreeBSD 10.3 64 bit system.

-3) Unzip it:
$ tar -xpzf /directory/of/ld_compat_linux64.tar.xz -C /

-4) In /boot/loader.conf add this:
linux64_load="YES"

-5) Reboot.

-6) Link your applications on a FreeBSD 64 system to produce Linux 64 executables and run it.

-7) Enjoy.

Fre;D
 
Back
Top