Page 1 of 1

Cross compiling C output with gcc/ld

Posted: Wed Nov 08, 2023 9:37 pm
by Yann64
I am investigating if it is possible to cross-compile Purebasic C output using a gcc/ld cross compiler (on linux x86_64).
I am using gcc and ld for the target architecture.

First step is extracting/getting the C code:

Code: Select all

pbcompilerc -c ./main.pb
Gives me a purebasic.c file.

Then compiling the code seem to be working (using the gcc for the target architecture):

Code: Select all

PBHOME=~/purebasic
PBINCLUDES="$PBHOME/sdk/c/PureLibraries"
gcc -c -I$PBINCLUDES ./purebasic.c
Gives me a purebasic.o file.

But using ld to link using *.a and *.o files return returns errors (missing symbols).

Which linker is being used for PureBasic on linux. Is it ld? And if yes, which libraries does it link against?

Re: Cross compiling C output with gcc/ld

Posted: Wed Nov 08, 2023 10:22 pm
by mk-soft
Not right way,

the pb compiler executes many compilation and linker options

See pbcompilerc help:
-ra, --reasm, /REASM: re-assembles the 'purebasic.asm' or 'purebasic.c' file into an executable. This allow to use the '--commented' option, modify the generated output and creates the executable again.
This option is for advanced programmers only.

Re: Cross compiling C output with gcc/ld

Posted: Thu Nov 09, 2023 6:39 am
by juergenkulow

Code: Select all

gcc -Xlinker --help