Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-pascal / 2003-06

cross compiler potential ?

15 messages · 5 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Harald Houppermans

Suppose I ever do get a free pascal compiler working.

How usefull will it be ?

What I want to do is write windows server software and then compile it for linux.

I would like to use: high performance counter, tcp/ip stack, udp protocol.

That's about it.

A step by step tutorial how to create such a cross compiler would be quite handy :D

1. Where do I get binutils from windows to linux ? Compiling it myself seems impossible... so many errors I am ready to give up on that. ( I tried mingw and cygwin, both with no luck )

2. What do I do after I have bin utils from windows to linux. ?

Later.

Reply by email

Nikolay Nikolov
to Harald Houppermans
Harald Houppermans wrote 11 lines
A step by step tutorial how to create such a cross compiler would be quite handy :D 1. Where do I get binutils from windows to linux ? Compiling it myself seems impossible... so many errors I am ready to give up on that. ( I tried mingw and cygwin, both with no luck ) 2. What do I do after I have bin utils from windows to linux. ? Later.

Never done that, but in theory it should happen this way (I think :) )

you need binutils for linux (elf) target, compiled for windows. you don't need all of the binutils, only the linker - "ld". (and also "as" - the assembler, but it's not really necessary since free pascal can use NASM instead, you can download it from nasm.sourceforge.net)

suppose you have ld.exe (for linux target), and nasm, you should install free pascal for win32, then download free pascal for linux, extract it to some directory and copy the RTL and the other units to c:\pp\units\linux (suppose fpc is installed in c:\pp which is the default)

then compile for linux with:
fpc -TLINUX -Anasmelf filename.pas

I have only cross-compiled units this way, not programs, since I don't have the linker from binutils - "ld", and fpc needs it to create an executable binary for linux.

Isn't it just simpler to install linux on your pc? (I mean linux is free, etc... that's why there are many resources on the web for cross-compiling from linux to windows or even from linux to dos and (almost) nothing for windows-->linux)
And you'll need linux for testing your programs anyway, because there are differences. :)

for tcp/ip you can use the sockets unit which is implemented on both windows and linux.

Reply by email

Harald Houppermans
to Nikolay Nikolov

----- Original Message -----

Earlier message 62 lines
From: "Nikolay Nikolov" To: Sent: Sunday, June 29, 2003 1:08 AM Subject: Re: [fpc-pascal]cross compiler potential ? > Harald Houppermans wrote: > > > A step by step tutorial how to create such a cross compiler would be > > quite handy :D > > > > 1. Where do I get binutils from windows to linux ? Compiling it myself > > seems impossible... so many errors I am ready to give up on that. > > ( I tried mingw and cygwin, both with no luck ) > > > > 2. What do I do after I have bin utils from windows to linux. ? > > > > Later. > > > > Never done that, but in theory it should happen this way (I think :) ) > > you need binutils for linux (elf) target, compiled for windows. you > don't need all of the binutils, only the linker - "ld". (and also "as" - > the assembler, but it's not really necessary since free pascal can use > NASM instead, you can download it from nasm.sourceforge.net) > > suppose you have ld.exe (for linux target), and nasm, you should install > free pascal for win32, then download free pascal for linux, extract it > to some directory and copy the RTL and the other units to > c:\pp\units\linux (suppose fpc is installed in c:\pp which is the default) > > then compile for linux with: > fpc -TLINUX -Anasmelf filename.pas > > I have only cross-compiled units this way, not programs, since I don't > have the linker from binutils - "ld", and fpc needs it to create an > executable binary for linux. > > Isn't it just simpler to install linux on your pc? (I mean linux is > free, etc... that's why there are many resources on the web for > cross-compiling from linux to windows or even from linux to dos and > (almost) nothing for windows-->linux) > And you'll need linux for testing your programs anyway, because there > are differences. :) > > for tcp/ip you can use the sockets unit which is implemented on both > windows and linux. Ok, I have now compiled the binutils-2.14 successfully I believe. ( using cygwin ) I need exact instructions what to do now... What do I do with the new ld.exe and as.exe ? Overwrite old, save them ? replace ? what ??? :) Ok... I already have linux source of free pascal etc... I go do that...

Reply by email

Nikolay Nikolov
to Harald Houppermans
Harald Houppermans wrote 8 lines
>then compile for linux with: >fpc -TLINUX -Anasmelf filename.pas > > Are these parameters based on the NASM idea ?

yes

What are the right parameters based on the binutils ?

the same, just without the -Anasmelf
fpc -TLINUX filename.pas

( Let s try binutils method first... before I get really confused :) )

ok.
1. install fpc for win32 in c:\pp
2. make sure that as.exe and ld.exe for linux target are in your path, and there are no other as and ld! the assembler and linker for win32, that comes with fpc are called asw.exe and ldw.exe (they should be in c:\pp\bin\win32) so they won't interfere. however the ones that come with cygwin and mingw will, so remove them from your path.
3. download binary.tar and extract it. inside there are several .tar.gz files, extract them somewhere, then copy everything from lib/fpc/1.0.x/units/linux/* to c:\pp\units\linux
that's all (I think)

Reply by email

Nikolai Zhubr
to Harald Houppermans: Suppose I ever do get a free pascal compiler working. How usefull will it be ? What I…

Hi,

Harald Houppermans wrote
Suppose I ever do get a free pascal compiler working. How usefull will it be ?

This depends entirely on how much you need it :)

What I want to do is write windows server software and then compile it for linux. I would like to use: high performance counter, tcp/ip stack, udp protocol.

Many programs will compile and run fine without any change on both windows and linux, provided you have respective FPC version installed on both systems. There is absolutely no need for (and probably no benefit from) crosscompiling to do this, unless you are prohibited to use linux :) Be aware however, that low-level network stuff is somewhat different on linux and windows (which has nothing to do with FPC though), so it might very well happen that the program you design for linux will not be compilable for windows or will not run on windows properly, and vice versa. High-performance things also tend to be platfrom-specific. I'd suppose you can find quite a lot of open-source server-related examples for *nix, hardly as many for windows. (Well, not in pascal may be, but anyway) I'm not much of an expert in this though...

Best regards, Nikolai Zhubr > That's about it. > A step by step tutorial how to create such a cross compiler would be quite handy :D > 1. Where do I get binutils from windows to linux ? Compiling it myself seems impossible... so many errors I am ready to give up on that. > ( I tried mingw and cygwin, both with no luck ) > 2. What do I do after I have bin utils from windows to linux. ? > Later.

Reply by email

Harald Houppermans
to Nikolai Zhubr

----- Original Message -----

Earlier message 38 lines
From: "Nikolai Zhubr" To: Sent: Sunday, June 29, 2003 2:45 AM Subject: Re: [fpc-pascal]cross compiler potential ? > Hi, > Saturday, 28 June, 2003, 22:26:01, Harald Houppermans wrote: > > Suppose I ever do get a free pascal compiler working. > > > How usefull will it be ? > This depends entirely on how much you need it :) > > > What I want to do is write windows server software and then compile it for linux. > > > I would like to use: high performance counter, tcp/ip stack, udp protocol. > Many programs will compile and run fine without any change on both windows > and linux, provided you have respective FPC version installed on both > systems. There is absolutely no need for (and probably no benefit from) > crosscompiling to do this, unless you are prohibited to use linux :) > Be aware however, that low-level network stuff is somewhat different on > linux and windows (which has nothing to do with FPC though), so it might > very well happen that the program you design for linux will not be > compilable for windows or will not run on windows properly, and vice versa. > High-performance things also tend to be platfrom-specific. I'd suppose > you can find quite a lot of open-source server-related examples for *nix, > hardly as many for windows. (Well, not in pascal may be, but anyway) > I'm not much of an expert in this though... Interesting post. Indeed difference between linux and windows should be remember somewhere in the back of my head :) Like endianess :)

Reply by email

Harald Houppermans
to Nikolay Nikolov: yes the same, just without the -Anasmelf fpc -TLINUX filename.pas ok. 1. install fpc for…

----- Original Message -----

Earlier message 77 lines
From: "Nikolay Nikolov" To: Sent: Sunday, June 29, 2003 2:33 AM Subject: Re: [fpc-pascal]cross compiler potential ? > Harald Houppermans wrote: > > >>then compile for linux with: > >>fpc -TLINUX -Anasmelf filename.pas > >> > >> > > > >Are these parameters based on the NASM idea ? > > > > > yes > > >What are the right parameters based on the binutils ? > > > the same, just without the -Anasmelf > fpc -TLINUX filename.pas > > >( Let s try binutils method first... before I get really confused :) ) > > > ok. > 1. install fpc for win32 in c:\pp > 2. make sure that as.exe and ld.exe for linux target are in your path, > and there are no other as and ld! the assembler and linker for win32, > that comes with fpc are called asw.exe and ldw.exe (they should be in > c:\pp\bin\win32) so they won't interfere. however the ones that come > with cygwin and mingw will, so remove them from your path. > 3. download binary.tar and extract it. inside there are several .tar.gz > files, extract them somewhere, then copy everything from > lib/fpc/1.0.x/units/linux/* to c:\pp\units\linux > that's all (I think) Ok thx... I got the linux units via mirc... someone with linux already had free pascasl 1.0.6 installed :) So I have all this stuff now... Someone else said to compile the linux rtl... that might not be needed now anymore.. Suppose I did have to compile the rtl... I am guessing I would have to go to: c:/pp/units/linux and then type the FPC stuff.. or isn't that the RTL ? Anyway... I have problems now with as-new.exe ( the binutils stuff ) It says: 'The procedure entry point asprintf could not be located in the dynamic link library cygwin1.dll" So I am ready to try that NASM stuff now :) Going to look into it :D I am also going to give mingw another try in case in previous attempts I used the wrong make also.. but I dont think so... I think mingw for some reason used the right make... but I go see :) right now :) Yep... msys always used the right make. $ which make /cygdrive/c/msys/1.0/bin/make Probably the way msys is started.

Reply by email

Harald Houppermans
to Nikolay Nikolov: yes the same, just without the -Anasmelf fpc -TLINUX filename.pas ok. 1. install fpc for…

Ok something strange is going on.

I copied as-new.exe and ld-new.exe to c:\pp\bin\linux

I also installed c:\pp\units\linux all kinds of linux units

I made a simple hello world program

begin
    writeln( 'hello world' );
end;

Called hellofp.pas

Now I try to compile it:

It says this:

C:\plztest2>fpc -TLINUX hellofps.pas
Free Pascal Compiler version 1.0.6 [2002/04/23] for i386 Copyright (c) 1993-2002 by Florian Klaempfl
Target OS: Linux for i386
Compiling hellofps.pas
Fatal: Can't open file hellofps.pas

Reply by email

Harald Houppermans

Shit lol...

Wrong file name ( also hello world program had end. not end; ;) )

Now it says this: :)

C:\plztest2>fpc -TLINUX hellofp
Free Pascal Compiler version 1.0.6 [2002/04/23] for i386 Copyright (c) 1993-2002 by Florian Klaempfl
Target OS: Linux for i386
Compiling hellofp.pas
Assembling program
Linking hellofp
5 Lines compiled, 3.8 sec

Now I am going to try it on knoppix and later on the red hat linux server ! :)

cooooool :)

Reply by email

Jonas Maebe
to Nikolay Nikolov: yes the same, just without the -Anasmelf fpc -TLINUX filename.pas ok. 1. install fpc for…
Nikolay Nikolov wrote 6 lines
1. install fpc for win32 in c:\pp 2. make sure that as.exe and ld.exe for linux target are in your path, and there are no other as and ld! the assembler and linker for win32, that comes with fpc are called asw.exe and ldw.exe (they should be in c:\pp\bin\win32) so they won't interfere. however the ones that come with cygwin and mingw will, so remove them from your path.

You can use the -FD command line switch to explicitly tell the compiler in which directory it should search for as, ld etc.

Jonas

Reply by email

Nikolay Nikolov
to Harald Houppermans: Hey wait a sec. What s the difference between binutils AS.exe and NASM... It seems NASM…
Harald Houppermans wrote 8 lines
Hey wait a sec. What s the difference between binutils AS.exe and NASM... It seems NASM is for 8086x and AS is for all kind of processors, is that correct ?

Nasm uses Intel-style assembler syntax, while AS uses AT&T, but that doesn't matter when you only use them as a compiler back-end. The reason I thought using Nasm with fpc would be easier is because you don't need to compile a cross-platform version as you have to with the binutils. I mean you just download the nasm binary for windows (or the dos version, it doesn't matter) and it can produce object files in different formats, including linux ELF. But then again, it doesn't matter, since you've already got AS running, and nasm doesn't have advantages over AS, when only used as a compiler back-end. :)

Reply by email

Marco van de Voort
to Harald Houppermans: ----- Original Message ----- From: "Nikolay Nikolov" To: Sent: Sunday, June 29, 2003 1:08…
Show quoted text 11 lines
> are differences. :) > > for tcp/ip you can use the sockets unit which is implemented on both > windows and linux. Ok, I have now compiled the binutils-2.14 successfully I believe. ( using cygwin ) I need exact instructions what to do now... What do I do with the new ld.exe and as.exe ?

Put them in a new directory with a descriptive name ( fpc\cross\x86-linux or so)

Then follow the already posted procedure:

fpc -Tlinux -FD\path\to\fpc\cross\x86-linux -Fu/path/to/fpc_linux_rtl/* sourcefile

Reply by email