How to generate compilable C code?

Just starting out? Need help? Post your questions and find answers here.
swhite
Addict
Addict
Posts: 805
Joined: Thu May 21, 2009 6:56 pm

How to generate compilable C code?

Post by swhite »

Hi

This maybe a dumb question as I have no experience with C or the GCC compiler in Linux but I was wondering whether the C code produced with the -c option is compilable by GCC? The reason I ask is that PB compiles my code from the IDE using the C Compiler without errors. However if I generate C code using the -c option and use GCC to compile it I get errors.

The back story is that I have a third party Linux web server that compiles Purebasic and C code automatically for use as scripts kind of like ISAPI extensions but for Linux. This third party tool works perfectly with PB 5.73 and compiles the PB code but I have not been able to get it to work with PB 6.20. However since it also handles C code I thought I might use PB 6.20 to generate usable C code instead.

Thanks
Simon
Simon White
dCipher Computing
User avatar
idle
Always Here
Always Here
Posts: 6026
Joined: Fri Sep 21, 2007 5:52 am
Location: New Zealand

Re: How to generate compilable C code?

Post by idle »

it's a little complicated, the PB generated c code is bound to pure basic libraries it's not independent of it.
So the problem isn't the compilation it's the linking of the libs and that's complicated as PB libs aren't directly useable they need extracting before linking.
User avatar
skywalk
Addict
Addict
Posts: 4241
Joined: Wed Dec 23, 2009 10:14 pm
Location: Boston, MA

Re: How to generate compilable C code?

Post by skywalk »

With the latest PB v6.20, gcc.exe is older.
What is the impediment to maintaining the latest gcc versions?

Code: Select all

c:\PureBasic-x64\Compilers\gcc>gcc --version
gcc (x86_64-win32-seh-rev2, Built by MinGW-W64 project) 12.2.0
Copyright (C) 2022 Free Software Foundation, Inc.
The nice thing about standards is there are so many to choose from. ~ Andrew Tanenbaum
swhite
Addict
Addict
Posts: 805
Joined: Thu May 21, 2009 6:56 pm

Re: How to generate compilable C code?

Post by swhite »

gcc --version
gcc (SUSE Linux) 7.5.0
Copyright (C) 2017 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
Are there some instruction about what is necessary to accomplish the linking?

Simon
Simon White
dCipher Computing
User avatar
mk-soft
Always Here
Always Here
Posts: 6315
Joined: Fri May 12, 2006 6:51 pm
Location: Germany

Re: How to generate compilable C code?

Post by mk-soft »

skywalk wrote: Sun Mar 09, 2025 2:25 am With the latest PB v6.20, gcc.exe is older.
What is the impediment to maintaining the latest gcc versions?

Code: Select all

c:\PureBasic-x64\Compilers\gcc>gcc --version
gcc (x86_64-win32-seh-rev2, Built by MinGW-W64 project) 12.2.0
Copyright (C) 2022 Free Software Foundation, Inc.
Same version on windows since v6.03

On Mint Linux actually same version
gcc (Debian 12.2.0-14) 12.2.0
Copyright (C) 2022 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
My Projects ThreadToGUI / OOP-BaseClass / EventDesigner V3
PB v3.30 / v5.75 - OS Mac Mini OSX 10.xx - VM Window Pro / Linux Ubuntu
Downloads on my Webspace / OneDrive
Post Reply