[SOLVED] Wanting to learn 'C' but gcc not installing

Questions about applications and software
Forum rules
Before you post read how to get help. Topics in this forum are automatically closed 6 months after creation.
Locked
bigal
Level 5
Level 5
Posts: 512
Joined: Mon Aug 03, 2009 3:26 am
Location: Pembrokeshire, South West Wales

[SOLVED] Wanting to learn 'C' but gcc not installing

Post by bigal »

I have decided it is about time I learned to program. Something I have never done before so am a total ignoramus. So I read up and found that I need ‘build essentials’ so after running

Code: Select all

sudo apt update
... Reading state information... Done
All packages are up-to-date.
to ensure my system was up to date attempted to install it.

Code: Select all

sudo apt install build-essential
Reading package lists... Done
Building dependency tree       
Reading state information... Done
Some packages could not be installed. This may mean that you have
requested an impossible situation or if you are using the unstable
distribution that some required packages have not yet been created
or been moved out of Incoming.
The following information may help to resolve the situation:

The following packages have unmet dependencies.
 build-essential : Depends: libc6-dev but it is not going to be installed or
                            libc-dev
                   Depends: g++ (>= 4:9.2) but it is not going to be installed
E: Unable to correct problems, you have held broken packages.
I have now spent a lot of time (days) reading up on this problem but am totally bemused by it all. Way, way, way out of my depth. Others, it seems have had the same problem but the discussions are all what to me is just gobbledegook. I have looked at these posts

viewtopic.php?f=47&t=349144

and

viewtopic.php?t=353624

and it seems that there is a bug

https://bugs.launchpad.net/ubuntu/+sour ... ug/1926918

I then found this

https://stackoverflow.com/questions/560 ... -install-g

but I am very hesitant about instructions like the ones suggested at the end of that post. I could blindly follow the instruction but I am trying to be cautious. I do not understand and don’t want to break my system.

Some info.

Code: Select all

$ inxi -Fxxxrz
System:    Kernel: 5.4.0-84-generic x86_64 bits: 64 compiler: gcc v: 9.3.0 Desktop: Cinnamon 5.0.5 wm: muffin 5.0.1 
           dm: LightDM 1.30.0 Distro: Linux Mint 20.2 Uma base: Ubuntu 20.04 focal 
Machine:   Type: Desktop System: HP-Pavilion product: FL230AA-ABU a6525.uk v: N/A serial: <filter> Chassis: Hewlett-Packard 
           type: 3 serial: <filter> 
           Mobo: N/A model: NARRA3 v: 3.02 serial: <filter> BIOS: Phoenix v: 5.13 date: 05/02/2008 
CPU:       Topology: Dual Core model: AMD Athlon 64 X2 4600+ bits: 64 type: MCP arch: K8 rev.F+ rev: 2 L2 cache: 1024 KiB 
           flags: lm nx pae sse sse2 sse3 svm bogomips: 9643 
           Speed: 1000 MHz min/max: 1000/2400 MHz Core speeds (MHz): 1: 1800 2: 1800 
Graphics:  Device-1: Advanced Micro Devices [AMD/ATI] RV620 LE [Radeon HD 3450] vendor: Micro-Star MSI driver: radeon 
           v: kernel bus ID: 02:00.0 chip ID: 1002:95c5 
           Display: x11 server: X.Org 1.20.11 driver: ati,radeon unloaded: fbdev,modesetting,vesa resolution: 1920x1080~60Hz 
           OpenGL: renderer: AMD RV620 (DRM 2.50.0 / 5.4.0-84-generic LLVM 12.0.0) v: 3.3 Mesa 21.0.3 compat-v: 3.0 
           direct render: Yes 
Audio:     Device-1: NVIDIA MCP61 High Definition Audio vendor: Hewlett-Packard driver: snd_hda_intel v: kernel 
           bus ID: 00:05.0 chip ID: 10de:03f0 
           Sound Server: ALSA v: k5.4.0-84-generic 
Network:   Device-1: NVIDIA MCP61 Ethernet vendor: Hewlett-Packard type: network bridge driver: forcedeth v: kernel port: ec00 
           bus ID: 00:07.0 chip ID: 10de:03ef 
           IF: enp0s7 state: down mac: <filter> 
           Device-2: Ralink RT5572 Wireless Adapter type: USB driver: rt2800usb bus ID: 1-2:3 chip ID: 148f:5572 
           serial: <filter> 
           IF: wlx48a9d29f38bc state: up mac: <filter> 
Drives:    Local Storage: total: 1.33 TiB used: 41.31 GiB (3.0%) 
           ID-1: /dev/sda vendor: Crucial model: CT500MX500SSD1 size: 465.76 GiB speed: 3.0 Gb/s serial: <filter> rev: 023 
           temp: 33 C scheme: MBR 
           ID-2: /dev/sdb vendor: Kingston model: SA400S37480G size: 447.13 GiB speed: 3.0 Gb/s serial: <filter> rev: 1103 
           temp: 24 C scheme: MBR 
           ID-3: /dev/sdc vendor: A-Data model: SU630 size: 447.13 GiB speed: 3.0 Gb/s serial: <filter> rev: 017a temp: 24 C 
           scheme: MBR 
Partition: ID-1: / size: 50.44 GiB used: 8.72 GiB (17.3%) fs: ext4 dev: /dev/sda6 
           ID-2: /boot size: 2.75 GiB used: 314.4 MiB (11.2%) fs: ext4 dev: /dev/sda5 
           ID-3: /home size: 5.57 GiB used: 22.9 MiB (0.4%) fs: ext4 dev: /dev/sdb5 
           ID-4: /var size: 23.34 GiB used: 2.58 GiB (11.1%) fs: ext4 dev: /dev/sda7 
Sensors:   System Temperatures: cpu: 35.0 C mobo: N/A 
           Fan Speeds (RPM): N/A 
Repos:     No active apt repos in: /etc/apt/sources.list 
           Active apt repos in: /etc/apt/sources.list.d/official-package-repositories.list 
           1: deb https://mirror.erickochen.nl/linuxmint/packages uma main upstream import backport
           2: deb http://archive.ubuntu.com/ubuntu focal main restricted universe multiverse
           3: deb http://archive.ubuntu.com/ubuntu focal-updates main restricted universe multiverse
           4: deb http://archive.ubuntu.com/ubuntu focal-backports main restricted universe multiverse
           5: deb http://security.ubuntu.com/ubuntu/ focal-security main restricted universe multiverse
           6: deb http://archive.canonical.com/ubuntu/ focal partner
Info:      Processes: 223 Uptime: 5h 48m Memory: 2.92 GiB used: 1.32 GiB (45.3%) Init: systemd v: 245 runlevel: 5 Compilers: 
           gcc: 9.3.0 alt: 9 Shell: bash v: 5.0.17 running in: gnome-terminal inxi: 3.0.38
Is there any other way I can just start to learn ‘C’. I am (was) going to uses the second edition of Kernnighan & Ritchie’s book as my guide.
Last edited by LockBot on Wed Dec 28, 2022 7:16 am, edited 2 times in total.
Reason: Topic automatically closed 6 months after creation. New replies are no longer allowed.
Lots of Minty machines but there again I like lamb and I do live in Wales!
Hoser Rob
Level 20
Level 20
Posts: 11796
Joined: Sat Dec 15, 2012 8:57 am

Re: Wanting to learn 'C' but gcc not installing

Post by Hoser Rob »

bigal wrote: Sat Sep 11, 2021 10:01 am I have decided it is about time I learned to program. Something I have never done ... Is there any other way I can just start to learn ‘C’. I am (was) going to uses the second edition of Kernnighan & Ritchie’s book as my guide.
C is actually one of the worst languages to begin learning programming. It's not a high level language, more medium level or a high level assembler.

And K & R's book probably IS the worst book for a beginner. It's written by and for pros.

If you want to start learning programming Python or perl scripting are much, much better choices.
For every complex problem there is an answer that is clear, simple, and wrong - H. L. Mencken
revmacian
Level 5
Level 5
Posts: 548
Joined: Wed May 27, 2020 1:50 pm
Location: United States

Re: Wanting to learn 'C' but gcc not installing

Post by revmacian »

Hoser Rob wrote: Sat Sep 11, 2021 10:42 am
bigal wrote: Sat Sep 11, 2021 10:01 am I have decided it is about time I learned to program. Something I have never done ... Is there any other way I can just start to learn ‘C’. I am (was) going to uses the second edition of Kernnighan & Ritchie’s book as my guide.
C is actually one of the worst languages to begin learning programming. It's not a high level language, more medium level or a high level assembler.

And K & R's book probably IS the worst book for a beginner. It's written by and for pros.

If you want to start learning programming Python or perl scripting are much, much better choices.
Agreed, I would begin with Python.. specifically Python 3. I have learned a few languages (BASIC, C++, Python) and Python 3 has been the easiest and most rewarding to learn. Much of your Mint system uses Python already so you likely already have everything you'll need besides an IDE. If you need an IDE there are some good ones, pycharm, Atom, VS Code, Sublime Text.

However, if you begin with Python, make sure the tutorials you choose match the version of Python that you are learning. The reason you need to match the tutorials is because there are language syntax differences between Python 2 and Python 3. If you do choose to go with Python 3, Start with this tutorial: https://docs.python.org/3/tutorial/
Give a man a fish and you'll feed him for a day. Teach a man to fish and you'll feed him for a lifetime.
US Navy, NEC HM8404
User avatar
GELvdH
Level 5
Level 5
Posts: 979
Joined: Tue Jan 08, 2019 10:10 am
Location: 3rd rock from Sun

Re: Wanting to learn 'C' but gcc not installing

Post by GELvdH »

I'l put my 2cents worth in, having gone through several languages over the last 60 years, From what I gather from the forum and other sources, Python is the better language rather than C.
bigal
Level 5
Level 5
Posts: 512
Joined: Mon Aug 03, 2009 3:26 am
Location: Pembrokeshire, South West Wales

Re: Wanting to learn 'C' but gcc not installing

Post by bigal »

Thank you both for your replies which I confess I just laughed at. My first attempt at a programming language, just under a week ago, was Python. My Grandsons are learning it. I found I had to have an IDE (I didn’t know that at first so that shows just how ignorant I was – and still am) but proptly got lost in a mire of suggestions as to which one. I turned to Perl as I have a book on that but of course the same problem arose. So then I turned to ‘C’ as I have had K & C’s book for ages but only previously managed the intro.

I’ll take your advice and try Python. However the saga still continues …

Looking around it seems that Pycharm IDE would appear to have the most ardent followers so I’ll go for that. However it seems that Pycharm IDE (community edition) is not in the Mint repositories so I have to install it manually. There is a guide here

https://techviewleo.com/how-to-install- ... inux-mint/

But - before I leap in would you be kind enough to give your opinion(s) of the instructions contained within please?
Lots of Minty machines but there again I like lamb and I do live in Wales!
bigal
Level 5
Level 5
Posts: 512
Joined: Mon Aug 03, 2009 3:26 am
Location: Pembrokeshire, South West Wales

Re: Wanting to learn 'C' but gcc not installing

Post by bigal »

GELvdH wrote: Sat Sep 11, 2021 11:11 am I'l put my 2cents worth in, having gone through several languages over the last 60 years, From what I gather from the forum and other sources, Python is the better language rather than C.
Thanks for that. I was typing my above reply and didn't get your input until after I posted.
Lots of Minty machines but there again I like lamb and I do live in Wales!
revmacian
Level 5
Level 5
Posts: 548
Joined: Wed May 27, 2020 1:50 pm
Location: United States

Re: Wanting to learn 'C' but gcc not installing

Post by revmacian »

bigal wrote: Sat Sep 11, 2021 11:21 am Thank you both for your replies which I confess I just laughed at. My first attempt at a programming language, just under a week ago, was Python. My Grandsons are learning it. I found I had to have an IDE (I didn’t know that at first so that shows just how ignorant I was – and still am) but proptly got lost in a mire of suggestions as to which one. I turned to Perl as I have a book on that but of course the same problem arose. So then I turned to ‘C’ as I have had K & C’s book for ages but only previously managed the intro.

I’ll take your advice and try Python. However the saga still continues …

Looking around it seems that Pycharm IDE would appear to have the most ardent followers so I’ll go for that. However it seems that Pycharm IDE (community edition) is not in the Mint repositories so I have to install it manually. There is a guide here

https://techviewleo.com/how-to-install- ... inux-mint/

But - before I leap in would you be kind enough to give your opinion(s) of the instructions contained within please?
Forget that website. I just downloaded and extracted pycharm to make sure my instructions were correct.

Download pycharm community edition from here: https://www.jetbrains.com/pycharm/downl ... tion=linux
Once downloaded go to the download location, right-click the downloaded file and choose "Extract here".
Once extracted, go into the pycharm-community-2021.2.1 folder and open the Install-Linux-tar.txt file.. that will teach you what you need to do to get pycharm up and running.
Last edited by revmacian on Sat Sep 11, 2021 11:32 am, edited 3 times in total.
Give a man a fish and you'll feed him for a day. Teach a man to fish and you'll feed him for a lifetime.
US Navy, NEC HM8404
bigal
Level 5
Level 5
Posts: 512
Joined: Mon Aug 03, 2009 3:26 am
Location: Pembrokeshire, South West Wales

Re: Wanting to learn 'C' but gcc not installing

Post by bigal »

P.S.

Can anyone recommend a good book on Python, suitable for an aged ignoramus.

I need some relaxing bedtime reading!
Lots of Minty machines but there again I like lamb and I do live in Wales!
rene
Level 20
Level 20
Posts: 12212
Joined: Sun Mar 27, 2016 6:58 pm

Re: Wanting to learn 'C' but gcc not installing

Post by rene »

bigal wrote: Sat Sep 11, 2021 11:21 am My first attempt at a programming language, just under a week ago, was Python. [ ... ]. I found I had to have an IDE
Note that this is not the case; you can use just any text editor to create a file e.g. ~/hello.py

Code: Select all

print('Hello, Python!')
and run it via python ~/hello.py from a terminal. More usually you'd use the standard UNIX-shebang method of starting the file with the interpreter to be used and making it executable:

Code: Select all

#!/usr/bin/env python
print('Hello, Python!')
and chmod +x ~/hello.py.

Hereafter you can run it simply as ~/hello.py, or just hello.py if you place it in a directory on your PATH rather than your home directory (if you use python3 specific features or syntax --- as even the above simplest program in fact does --- you may want to say python3 rather than plain python in command line or shebang if python2 is default on your system).

PyCharm is not bad, but I in fact advise starting without, so as to not mix learning Python as such with learning the specific programming environment; advise to only do latter once you're at least mildly used to former lest you'd conflate too many issues.

For someone already competent in another language it's too slow but when learning Python as a first language I advise

https://www.amazon.com/Learning-Python- ... 1449355730

Possibly together with the compact

https://www.amazon.com/Python-Pocket-Re ... 1449357016

if you like short/to-the-point reference-type books also/instead.

Finally; note that starting with C would not in fact be bad, even if depending on what you want to achieve. The thing about knowing C is that you basically know most of the rest as well (well, the procedural rest) whereas conversely this is not the case: a C programmer has little trouble pounding something out in Python but a Python programmer is only mildly less lost in C than a non-programmer. This is a reflection of the fact that C requires you to DIY a lot; Python being much quicker to the point for not low-level tasks, and Python is in fact a good language, so advised --- but should you insist on C, may feel free...
revmacian
Level 5
Level 5
Posts: 548
Joined: Wed May 27, 2020 1:50 pm
Location: United States

Re: Wanting to learn 'C' but gcc not installing

Post by revmacian »

rene wrote: Sat Sep 11, 2021 11:59 am
bigal wrote: Sat Sep 11, 2021 11:21 am My first attempt at a programming language, just under a week ago, was Python. [ ... ]. I found I had to have an IDE
Note that this is not the case; you can use just any text editor to create a file e.g. ~/hello.py

Code: Select all

print('Hello, Python!')
and run it via python ~/hello.py from a terminal. More usually you'd use the standard UNIX-shebang method of starting the file with the interpreter to be used and making it executable:

Code: Select all

#!/usr/bin/env python
print('Hello, Python!')
and chmod +x ~/hello.py.

Hereafter you can run it simply as ~/hello.py, or just hello.py if you place it in a directory on your PATH rather than your home directory (if you use python3 specific features or syntax --- as even the above simplest program in fact does --- you may want to say python3 rather than plain python in command line or shebang if python2 is default on your system).

PyCharm is not bad, but I in fact advise starting without, so as to not mix learning Python as such with learning the specific programming environment; advise to only do latter once you're at least mildly used to former lest you'd conflate too many issues.

For someone already competent in another language it's too slow but when learning Python as a first language I advise

https://www.amazon.com/Learning-Python- ... 1449355730

Possibly together with the compact

https://www.amazon.com/Python-Pocket-Re ... 1449357016

if you like short/to-the-point reference-type books also/instead.

Finally; note that starting with C would not in fact be bad, even if depending on what you want to achieve. The thing about knowing C is that you basically know most of the rest as well (well, the procedural rest) whereas conversely this is not the case: a C programmer has little trouble pounding something out in Python but a Python programmer is only mildly less lost in C than a non-programmer. This is a reflection of the fact that C requires you to DIY a lot; Python being much quicker to the point for not low-level tasks, and Python is in fact a good language, so advised --- but should you insist on C, may feel free...
Good point, you don't even need a full IDE.. I started learning Python 3 using Xed (ships with Mint Cinnamon). There is also IDLE (in the repos) that works just fine on its own.
Give a man a fish and you'll feed him for a day. Teach a man to fish and you'll feed him for a lifetime.
US Navy, NEC HM8404
rene
Level 20
Level 20
Posts: 12212
Joined: Sun Mar 27, 2016 6:58 pm

Re: Wanting to learn 'C' but gcc not installing

Post by rene »

IDLE I can agree with; it's minimal enough to not distract from Python itself and its interactive terminal can be useful, but even in that case I'd save it for week 2 just so as to further for evermore naturally delineate between Python as such and tools you use to create Python programs with. I.e., when writing a novel you should also not start by learning Microsoft Word but by writing the darned novel.
User avatar
GELvdH
Level 5
Level 5
Posts: 979
Joined: Tue Jan 08, 2019 10:10 am
Location: 3rd rock from Sun

Re: Wanting to learn 'C' but gcc not installing

Post by GELvdH »

Just saw this article, might be of interest.
https://www.makeuseof.com/how-to-learn-python-for-free/
bigal
Level 5
Level 5
Posts: 512
Joined: Mon Aug 03, 2009 3:26 am
Location: Pembrokeshire, South West Wales

Re: Wanting to learn 'C' but gcc not installing

Post by bigal »

One of the great advantages of Linux Mint, and one of the reasons I always recommend it to prospective or new users is this forum. With only one single exception, nowhere else, and I am a great forum fan, have I ever found such a helpful and kind group of people so willing to give up their time to help others.

At my age I am way past the time when I need any kind of certification to say that I am “competent” or that I have “completed” a course in this or that. It is simply that have a burning desire to learn. But to learn only for my own interest; a need to keep the brain busy perhaps? Wanting to know more. In view of that I have gone the IDLE route and have started to work through the tutorials provide by Python

https://docs.python.org/3.9/contents.html

I can work through them at my own pace and don’t need to sign up for anything. IDLE is easily available in the repositories, is small and easy to use so no additional learning curve and is needed.

I’m on the way.

Thank you to everyone who has contributed to this post. The suggestion that you have all so kindly provided have been just what I needed to bring into focus my random thoughts on where to start. I am very grateful to you all.

I shall mark this post as ‘Solved’ as it well and truly is.
Lots of Minty machines but there again I like lamb and I do live in Wales!
teepeeaye
Level 1
Level 1
Posts: 24
Joined: Tue Jul 20, 2010 5:14 pm

Re: [SOLVED] Wanting to learn 'C' but gcc not installing

Post by teepeeaye »

A good programming language also depends what you want. Octave could be considered a programming language. And Pascal is rather "human". Free Pascal (text mode IDE) is very Turbo Pascal like. If you want to discuss with other Python is probably the way to go as C, Pascal and FORTRAN are less frequent. To most old school Unix users C is something special.

Python with IDE and a lot more: www.spyder-ide.org
bigal
Level 5
Level 5
Posts: 512
Joined: Mon Aug 03, 2009 3:26 am
Location: Pembrokeshire, South West Wales

Re: [SOLVED] Wanting to learn 'C' but gcc not installing

Post by bigal »

teepeeaye wrote: Mon Sep 20, 2021 12:35 pm A good programming language also depends what you want.
Hi Teepeeaye.

Spot on. I had no real ‘target’ when I set out to learn a language as the desire came just from a desire to learn and so keep my brain active. At my age I have no need to actually know any computing language, or anything else for that matter. As I said earlier I have no need of any qualifications or certificates. I also do not need the pressure of a fixed, or even a flexible timed course. I have other interests as well as computing to pursue and there are only so many hours in a day.

I have started with Python and will not no confuse myself by jumping in with something else.

Thank you for you interest and suggestions which are always welcome. You never know when they might come in useful.
Lots of Minty machines but there again I like lamb and I do live in Wales!
ivar
Level 5
Level 5
Posts: 617
Joined: Sun Mar 21, 2021 10:30 pm
Location: far north

Re: [SOLVED] Wanting to learn 'C' but gcc not installing

Post by ivar »

bigal wrote: Mon Sep 20, 2021 2:00 pm I had no real ‘target’ when I set out to learn a language as the desire came just from a desire to learn and so keep my brain active.
I've found that my brain is most responsive to picking up new skills when I have something to apply that newfound knowledge to :D

So, I got myself one of these , a Raspberry Pi, lots of interesting stuff that can be done with it:
https://www.youtube.com/watch?v=41IO4Qe5Jzw
teepeeaye
Level 1
Level 1
Posts: 24
Joined: Tue Jul 20, 2010 5:14 pm

Re: [SOLVED] Wanting to learn 'C' but gcc not installing

Post by teepeeaye »

And - for the more old school conservative type - don't underestimate the powers of your command interpreter (the "shell" - most likely bash, csh) which in combination with the many good textbased programs being a part of you basic linux/unix system (awk, sed, sort, col). It is possible for example to make a shell script which prepares input data which may be given a mathematical treatment with octave, and the saved output data from octave can then be further processed by the shell script.
Essentially progamming is a lot like planning on a work place. It is a forecast of what is going to happen on the path to the goal. On the path some special capabilities and ressources may be needed. Also a good plan/program involves some occasional quality control and follow up. It is the job of the boss/programmer to make sure that the goal is well defined, and capabilities and ressources are available when needed and to check that the plan is followed.

A good programming practice is to always start making a flow chart (try google'ing that) which is a graphic presentation of the process flow of your program. This is something we always started with in the old days (before the trial and error approach which came along with the IDEs).

It is all quite fun, actually. Good luck 8)
Locked

Return to “Software & Applications”