How to cross compile to another platform?

General discussion for topics related to the FreeBASIC project or its community.
Post Reply
Cretin Ho
Posts: 182
Joined: Feb 04, 2021 13:01

How to cross compile to another platform?

Post by Cretin Ho »

I'm on Linux. I want to compile for the Solaris target. How could I do it? Could I have fbc to generate binaries for me or it will only generate C sources and I have to use the gcc cross compiler to have the binaries? I already have the gcc cross compiler working. Please help me with the proper procedures. Thanks.

p/s: I have the fbc on Solaris port working fine already with a few caveats, this is about cross compiler from Linux for Solaris.
Xusinboy Bekchanov
Posts: 789
Joined: Jul 26, 2018 18:28

Re: How to cross compile to another platform?

Post by Xusinboy Bekchanov »

Cretin Ho wrote:I'm on Linux. I want to compile for the Solaris target. How could I do it? Could I have fbc to generate binaries for me or it will only generate C sources and I have to use the gcc cross compiler to have the binaries? I already have the gcc cross compiler working. Please help me with the proper procedures. Thanks.

p/s: I have the fbc on Solaris port working fine already with a few caveats, this is about cross compiler from Linux for Solaris.
When compiling, there is the -target key
Cretin Ho
Posts: 182
Joined: Feb 04, 2021 13:01

Re: How to cross compile to another platform?

Post by Cretin Ho »

Xusinboy Bekchanov wrote:
Cretin Ho wrote:I'm on Linux. I want to compile for the Solaris target. How could I do it? Could I have fbc to generate binaries for me or it will only generate C sources and I have to use the gcc cross compiler to have the binaries? I already have the gcc cross compiler working. Please help me with the proper procedures. Thanks.

p/s: I have the fbc on Solaris port working fine already with a few caveats, this is about cross compiler from Linux for Solaris.
When compiling, there is the -target key
More information? Does this generate C sources or binaries directly? I know I should just try it myself, but I don't have my computer now. Posting from guest account on a public PC.
Xusinboy Bekchanov
Posts: 789
Joined: Jul 26, 2018 18:28

Re: How to cross compile to another platform?

Post by Xusinboy Bekchanov »

Cretin Ho wrote:
Xusinboy Bekchanov wrote:
Cretin Ho wrote:I'm on Linux. I want to compile for the Solaris target. How could I do it? Could I have fbc to generate binaries for me or it will only generate C sources and I have to use the gcc cross compiler to have the binaries? I already have the gcc cross compiler working. Please help me with the proper procedures. Thanks.

p/s: I have the fbc on Solaris port working fine already with a few caveats, this is about cross compiler from Linux for Solaris.
When compiling, there is the -target key
More information? Does this generate C sources or binaries directly? I know I should just try it myself, but I don't have my computer now. Posting from guest account on a public PC.
-gen gcc creates a C file and compiles with gcc (without user intervention). -gen gas and -gen gas64 create binary files directly (without C code). On Unix like systems the default is -gen gcc.
Cretin Ho
Posts: 182
Joined: Feb 04, 2021 13:01

Re: How to cross compile to another platform?

Post by Cretin Ho »

Xusinboy Bekchanov wrote:
Cretin Ho wrote:
Xusinboy Bekchanov wrote: When compiling, there is the -target key
More information? Does this generate C sources or binaries directly? I know I should just try it myself, but I don't have my computer now. Posting from guest account on a public PC.
-gen gcc creates a C file and compiles with gcc (without user intervention). -gen gas and -gen gas64 create binary files directly (without C code). On Unix like systems the default is -gen gcc.
Yeah I know but which gcc? For example, the target is Solaris. Does it invoke the system's gcc (incorrect, this gcc generates binary for Linux) or my x86_64-pc-sun2.11-gcc (correct, this is the cross compiler that generates binary for Solaris)? This is the piece of information I wanted to know.
Xusinboy Bekchanov
Posts: 789
Joined: Jul 26, 2018 18:28

Re: How to cross compile to another platform?

Post by Xusinboy Bekchanov »

Cretin Ho wrote:
Xusinboy Bekchanov wrote:
Cretin Ho wrote: More information? Does this generate C sources or binaries directly? I know I should just try it myself, but I don't have my computer now. Posting from guest account on a public PC.
-gen gcc creates a C file and compiles with gcc (without user intervention). -gen gas and -gen gas64 create binary files directly (without C code). On Unix like systems the default is -gen gcc.
Yeah I know but which gcc? For example, the target is Solaris. Does it invoke the system's gcc (incorrect, this gcc generates binary for Linux) or my x86_64-pc-sun2.11-gcc (correct, this is the cross compiler that generates binary for Solaris)? This is the piece of information I wanted to know.
Whichever target, that's what gcc uses. For example: -target androideabi. Uses androideabi-gcc
Cretin Ho
Posts: 182
Joined: Feb 04, 2021 13:01

Re: How to cross compile to another platform?

Post by Cretin Ho »

Xusinboy Bekchanov wrote:
Cretin Ho wrote:
Xusinboy Bekchanov wrote: -gen gcc creates a C file and compiles with gcc (without user intervention). -gen gas and -gen gas64 create binary files directly (without C code). On Unix like systems the default is -gen gcc.
Yeah I know but which gcc? For example, the target is Solaris. Does it invoke the system's gcc (incorrect, this gcc generates binary for Linux) or my x86_64-pc-sun2.11-gcc (correct, this is the cross compiler that generates binary for Solaris)? This is the piece of information I wanted to know.
Whichever target, that's what gcc uses. For example: -target androideabi. Uses androideabi-gcc
Thanks. But this now arising a new problem. The target is named solaris, but the cross compiler is actually named x86_64-pc-sun2.11-gcc, this will caused mismatch.
Xusinboy Bekchanov
Posts: 789
Joined: Jul 26, 2018 18:28

Re: How to cross compile to another platform?

Post by Xusinboy Bekchanov »

Cretin Ho wrote:
Xusinboy Bekchanov wrote:
Cretin Ho wrote: Yeah I know but which gcc? For example, the target is Solaris. Does it invoke the system's gcc (incorrect, this gcc generates binary for Linux) or my x86_64-pc-sun2.11-gcc (correct, this is the cross compiler that generates binary for Solaris)? This is the piece of information I wanted to know.
Whichever target, that's what gcc uses. For example: -target androideabi. Uses androideabi-gcc
Thanks. But this now arising a new problem. The target is named solaris, but the cross compiler is actually named x86_64-pc-sun2.11-gcc, this will caused mismatch.
You can use any C compiler. You must use the -r or -R compiler switches to do this. Then the generated C file will not be deleted. And compile this C file with your favorite compiler.
Post Reply