You are not logged in.

#26 2026-10-04 18:08:25

reggieArchExpert
Member
Registered: 2026-08-11
Posts: 27

Re: [SOLVED] How do I run C Applications?

cryptearth wrote:

your actual question: "How do I run C Applications?"
your actual issue: wrongly using -c by not understanding it
what my link provides: a goid explanation of how a source file turns into an executable - and why several others tried to get into your brain: "just get rid of '-c' and '.o' but only call 'gcc -o main main.c'"

You realized you are still trying to answer a question that was already marked as solved by the person who asked it(me). So thus your link has very little use for me

Offline

#27 2026-10-04 18:40:20

reggieArchExpert
Member
Registered: 2026-08-11
Posts: 27

Re: [SOLVED] How do I run C Applications?

dimich wrote:
reggieArchExpert wrote:

as though the gcc#c manual is appreciated, it fails to give a verbose in-depth explanation

Process of building executable from sources is not specific for GCC. MSVC, Turbo / Borland C, Watcom C and many other work the same way.
GCC manual page is not a tutorial. It doesn't and should not explain what to do, it explains how to perform one or another operation with gcc command.

Interesting how you seem to care so much about specifics, yet failed to quote the entirety of my statement on the gcc manual. As I have said before, if you read the entire statement instead of cherry-picking, it's clear that many of the things you are apparently criticizing me for(like i.e 'expecting the gcc manual page to be a tutorial') is not only untrue but as well unfairly misrespresents what was actually said as I clarified on the very same sentence that I understood that the way the gcc manual is currently is intentional and is simply following how manuals are supposed to be in the first place.

Offline

#28 2026-10-04 18:41:45

reggieArchExpert
Member
Registered: 2026-08-11
Posts: 27

Re: [SOLVED] How do I run C Applications?

loqs wrote:

Plugins example; each plugin uses the flags for the library it will be using (each plugin will be its own binary so they will not be combined together):

gcc -o plugins/mariadb/maria_conn.o plugins/mariadb/maria_conn.c $(pkg-config --cflags libmariadb)
gcc -o plugins/postgres/pg_conn.o plugins/postgres/pg_conn.c $(pkg-config --cflags libpq) -D_POSIX_C_SOURCE=200809L
gcc -o plugins/sqlite/sqlite_conn.o plugins/sqlite/sqlite_conn.c $(pkg-config --cflags sqlite3) -DSQLITE_THREADSAFE=1

Runtime optimization selection example while avoiding optimizing the whole project (in this example all the units will be combined together (not shown)):

gcc -o codec/generic.o codec/generic.c
gcc -o codec/sse41.o codec/sse41.c -msse4.1 -mno-avx
gcc -o codec/avx2.o codec/avx2.o -mavx2

Thank you!

Offline

#29 2026-10-04 18:46:38

SimonJ
Member
Registered: 2021-05-11
Posts: 390
Website

Re: [SOLVED] How do I run C Applications?

reggieArchExpert wrote:

You realized you are still trying to answer a question that was already marked as solved by the person who asked it(me). So thus your link has very little use for me

The title is supposed to be prepended with the solved, it's confusing when it is not.

Offline

#30 2026-10-04 19:33:55

reggieArchExpert
Member
Registered: 2026-08-11
Posts: 27

Re: [SOLVED] How do I run C Applications?

SimonJ wrote:
reggieArchExpert wrote:

You realized you are still trying to answer a question that was already marked as solved by the person who asked it(me). So thus your link has very little use for me

The title is supposed to be prepended with the solved, it's confusing when it is not.

Updated

Offline

#31 2026-10-04 19:50:22

cryptearth
Member
Registered: 2024-02-03
Posts: 2,376

Re: [SOLVED] How do I run C Applications?

avoid full quotes
also: i reiterated because to me your "i got it done [someone]" didn't cnvey a proper "i actually understood my mistake" (which i still doubt)
also also: it was actually you who asked me "and what does your link [i don't cared to read / didn't understood] is/was supposed to tell/teach me?" as i replied with it twice and at least the first time you seem to have ignored it

quite honestly: if you keep going further i suspect we'll other topics about things that were already answered
as many i warmly recommend you get a copy of "the K & R" - it'll teach you the very basics from the guys who invented the language

Offline

#32 2026-10-04 20:08:56

loqs
Member
Registered: 2014-03-06
Posts: 19,101

Re: [SOLVED] How do I run C Applications?

K & R C second edition uses C89 which has some incompatibilities with ISO C23 and newer, the first edition covering K&R C will not work on any modern compiler without at least setting -std.

Offline

#33 2026-10-05 02:51:43

cryptearth
Member
Registered: 2024-02-03
Posts: 2,376

Re: [SOLVED] How do I run C Applications?

have a 4th edition and worked through it over about the last 12 months or so - did not encouter any issue as far as i remember - but thanks for the additional info about incompatibilities due to age *thumbs up

Offline

#34 2026-10-05 03:43:24

loqs
Member
Registered: 2014-03-06
Posts: 19,101

Re: [SOLVED] How do I run C Applications?

I have the second edition so that explains the difference.  Makes me feel old.

Offline

#35 2026-10-05 06:53:27

seth
Member
From: Won't reply 2 private help req
Registered: 2012-09-03
Posts: 78,473

Re: [SOLVED] How do I run C Applications?

You *are* old if you bought it on release but @cryptearth might be talking about some derivative that just namedrops K&R in the title (or a reprint counter) - there's no 4th edition (nor a third one)

Offline

#36 2026-10-05 16:05:27

mpan
Member
Registered: 2012-08-01
Posts: 1,669
Website

Re: [SOLVED] How do I run C Applications?

“Some compatibilities” is an understatement. If almost every example needs corrections, an additional “but in 21st century” added, and is likely to imbue the novice with poor ideas, I can’t recommend this for beginners. Even if I can’t offer anything else, this 38 year old publication may be good for tracking back C language’s history, not learning it.

Per Kernighan’s site, the 2nd edition from 1988 is the latest one. Perhaps cryptearth means a translation? They are separate works and use separate edition counters.

Offline

#37 2026-10-05 17:05:15

cryptearth
Member
Registered: 2024-02-03
Posts: 2,376

Re: [SOLVED] How do I run C Applications?

have to correct myself: it is 2nd edition - but from what i get the 4th reprint
978-0-13-110362-7
0-13-110362-8
and at least my "print" really looks like a 4th copy of a 3rd copy of a 2nd copy of a 1st copy of the 2nd edition - i can quite tell it looks like soneone scanned the previous copy and reprinted that as bad resolution image instead of ocr the text and print fresh as text

Offline

#38 2026-10-06 01:19:01

cfr
Member
From: Cymru
Registered: 2011-11-27
Posts: 7,198

Re: [SOLVED] How do I run C Applications?

I am not qualified to judge the quality, but I have found this useful as a beginner and I've been told by people who do know C that it looks to be of decent quality: https://beej.us/guide/bgc/. It includes some C23 features, but not everything has been updated yet.

I cannot say anything about the end as I have not worked through all of it yet. But I've found the first 25+ or so chapters helpful.


CLI Paste | How To Ask Questions

Arch Linux | x86_64 | GPT | EFI boot | refind | stub loader | systemd | LVM2 on LUKS
Lenovo x270 | Intel(R) Core(TM) i5-7200U CPU @ 2.50GHz | Intel Wireless 8265/8275 | US keyboard w/ Euro | 512G NVMe INTEL SSDPEKKF512G7L

Offline

Board footer

Powered by FluxBB