Scheduled Maintenance: We are aware of an issue with Google, AOL, and Yahoo services as email providers which are blocking new registrations. We are trying to fix the issue and we have several internal and external support tickets in process to resolve the issue. Please see: viewtopic.php?t=158230
Setting up a C programming environment
Setting up a C programming environment
greetings.
I am getting myself set up for C programming on the latest Debian Jessie. In the Debian Reference Manual they recommend the following command to set up the environment.
# apt-get install glibc-doc manpages-dev libc6-dev gcc build-essential
My question is should I be using the package gcc-4.9 instead of just gcc in the above command, in order to get the latest stable version. It's not clear to me what the difference is between the two packages.
https://www.debian.org/doc/manuals/debi ... en.html#_c
https://packages.debian.org/stable/devel/gcc
https://packages.debian.org/stable/devel/gcc-4.9
I am getting myself set up for C programming on the latest Debian Jessie. In the Debian Reference Manual they recommend the following command to set up the environment.
# apt-get install glibc-doc manpages-dev libc6-dev gcc build-essential
My question is should I be using the package gcc-4.9 instead of just gcc in the above command, in order to get the latest stable version. It's not clear to me what the difference is between the two packages.
https://www.debian.org/doc/manuals/debi ... en.html#_c
https://packages.debian.org/stable/devel/gcc
https://packages.debian.org/stable/devel/gcc-4.9
- ralph.ronnquist
- Posts: 342
- Joined: 2015-12-19 01:07
- Location: Melbourne, Australia
- Been thanked: 6 times
Re: Setting up a C programming environment
Hi,
the difference between gcc-4.9 and gcc is, that gcc is a meta package which depends on the latest avaiable gcc version (which is gcc-4.9 in the jessie repos). So if you need explicit the 4.9 version you should install the gcc-4.9 package.
the difference between gcc-4.9 and gcc is, that gcc is a meta package which depends on the latest avaiable gcc version (which is gcc-4.9 in the jessie repos). So if you need explicit the 4.9 version you should install the gcc-4.9 package.
Have a nice day!
- ralph.ronnquist
- Posts: 342
- Joined: 2015-12-19 01:07
- Location: Melbourne, Australia
- Been thanked: 6 times
Re: Setting up a C programming environment
Well, gcc-4.9 does not install cpp, which comes with gcc. However, build-essential depends on gcc, so it'll be installed anyhow, and all in all you wouldn't have needed to be confused at all about which to install.
Re: Setting up a C programming environment
There's a bug in jessie repositories: gcc should be a "meta-package" referencing the gcc v4.9.2-10 but it is claiming that it'll install the gcc v4.9.2-2
Most likely, it'll install the gcc v4.9.2-10, simply because only the package name was not updated yet, but the safest way is to directly install the gcc v4.9.2-10 package.
Also, You should make sure to install gcc-doc or better gcc-4.9-doc package to have the manpage for gcc.
Regards.
Most likely, it'll install the gcc v4.9.2-10, simply because only the package name was not updated yet, but the safest way is to directly install the gcc v4.9.2-10 package.
Also, You should make sure to install gcc-doc or better gcc-4.9-doc package to have the manpage for gcc.
Regards.
Odi profanum vulgus
Re: Setting up a C programming environment
Well, I'm just learning C, so I don't suppose it really matters whether I have gcc v4.9.2-2 or gcc v4.9.2-10, assuming there really is a v4.9.2-2 in the first place. Also I expect that gcc is important enough that is there really was a critical bug in the repository that someone would have picked up on it by now.
So, when it's all said and done, my inclination is to just follow the command as it appears in the reference manual, which installs gcc the metapackage. If something goes wrong it ain't the end of the world.
Thanks for the replies.
So, when it's all said and done, my inclination is to just follow the command as it appears in the reference manual, which installs gcc the metapackage. If something goes wrong it ain't the end of the world.
Thanks for the replies.
Re: Setting up a C programming environment
Definitely there's no a big difference between compilers at the learning stage - but those differences are becoming just huge at a professional level (like f.e. the way of handling bitfields or transparent structures)
You've asked about the gcc v4.9 and You've got the answer - responsiblity is on Your side
Regards.
You've asked about the gcc v4.9 and You've got the answer - responsiblity is on Your side
Regards.
Odi profanum vulgus
Re: Setting up a C programming environment
Well, just to close the book on this ...
I ended up installing gcc using the following command apt install gcc libc6.dev gcc.doc
I didn't go with the build-essential because it said on debian.org that you only needed that if you are developing debian packages.
Anyways, gcc -v shows gcc version 4.9.2 (Debian 4.9.2-10) which I guess is what I wanted.
Also I managed to compile and run a simple C program so I guess all is well.
Is there anything I missed?
I ended up installing gcc using the following command apt install gcc libc6.dev gcc.doc
I didn't go with the build-essential because it said on debian.org that you only needed that if you are developing debian packages.
Anyways, gcc -v shows gcc version 4.9.2 (Debian 4.9.2-10) which I guess is what I wanted.
Also I managed to compile and run a simple C program so I guess all is well.
Is there anything I missed?
- ralph.ronnquist
- Posts: 342
- Joined: 2015-12-19 01:07
- Location: Melbourne, Australia
- Been thanked: 6 times
Re: Setting up a C programming environment
You may want to learn and use make as well, and also of course version control, though I might be too old-fashioned to give a good pointer on that; perhaps mercurial could be a choice.
Re: Setting up a C programming environment
No.ralph.ronnquist wrote:You may want to learn and use make as well, and also of course version control, though I might be too old-fashioned to give a good pointer on that; perhaps mercurial could be a choice.
@fguy:
I understand that You've just started the learning process - so You should follow the *right* suggestions.
Make: (or cmake, or derivatives) don't use it: it's just an outdated build system, with a lots of bugs/problems. If your project will grow to the point where a build system is starting to become necessary -> learn autotools (autoconf/automake/libtool). Make build system is a crap - it fails in so many scenarios that i'll be just a waste of time to even try to discuss it.
Mercurial: advertisements are sounding good, but literally (almost) *nobody* is using it. Serious developers are using svn or git. (sourceforge.net or github.com)
Now back to the topic:
Sooner or later Your project(s) will grow in the sense of the number of lines and files. Imagine that one day You'll need to modify/change a structure which is used/referenced 125 times in different src files or headers - this is happening quite often with software projects - then what?
Most of the forums are spreading bullshits about "how to write programs in <some language>" - as most of the answers are: You can just use a text editor.
Well, for a "hello world" that could be fine.
My latest project has about 30'000 lines of code and ~60 files. It's simply impossible to use a dumb text editor for such project - even such trivial thing like changing some global variable name would take minutes (at best).
This is where IDEs are coming in - and sooner or later You'll be sentenced to use one of such programs.
There are plenty of IDEs, which are sometimes called "smart editors" - like EMACS - but the truth is: You'll need some kind of an IDE to efficiently write the code.
My suggestion is: it's better to start writing Your code in some IDE, because f.e.syntax highlighting will make the learning process faster.
Regards.
PS.
I'm using Code::Blocks IDE for years - it does the job for me.
Odi profanum vulgus
Re: Setting up a C programming environment
Thanks for the tips. Yeah I am using Code::Blocks v 13.12 that I got from jessie-backports. CB worked great for me when I was using Windows, but now that I have switched to Jessie 8.4 running Xfce v4.10 desktop, CB is acting a little flaky, occasionally just shutting itself down and I lose unsaved work. I'm not sure what the problem is, but I am starting to look for an alternative.
Re: Setting up a C programming environment
Code::Blocks project is now switching from wxwidgets 2.8.x to 3.1.x - this is a long process. Unfortunately, the only way to get latest "stable" build is to not use the versions which are available in the repos - the stable C::B can be obtained from nightly builds - but that's another story...fguy wrote:Thanks for the tips. Yeah I am using Code::Blocks v 13.12 that I got from jessie-backports. CB worked great for me when I was using Windows, but now that I have switched to Jessie 8.4 running Xfce v4.10 desktop, CB is acting a little flaky, occasionally just shutting itself down and I lose unsaved work. I'm not sure what the problem is, but I am starting to look for an alternative.
Anyway, it was was just an example - there're other stable IDE's - like f.e. Eclipse + CDT, but this is not the point here - You need an editor with a dependancy tracking, based on a variable symbol definitions - an IDE.
Regards.
Odi profanum vulgus
Re: Setting up a C programming environment
I see on the CODE::Blocks download page there is a link to a file codeblocks_16.01_amd64_jessie.tar.xz which is their latest official release so maybe I'll give that a try. I'd like to stay with CB if I can, programming is my main hobby and I like to stay with things that have worked for me in the past. Unfortunately, I am even more of a rookie at Linux than I am with C, so I'll have to do some homework before I attempt an install that is not using the APT systemtomazzi wrote:Code::Blocks project is now switching from wxwidgets 2.8.x to 3.1.x - this is a long process. Unfortunately, the only way to get latest "stable" build is to not use the versions which are available in the repos - the stable C::B can be obtained from nightly builds - but that's another story...fguy wrote:Thanks for the tips. Yeah I am using Code::Blocks v 13.12 that I got from jessie-backports. CB worked great for me when I was using Windows, but now that I have switched to Jessie 8.4 running Xfce v4.10 desktop, CB is acting a little flaky, occasionally just shutting itself down and I lose unsaved work. I'm not sure what the problem is, but I am starting to look for an alternative.
Anyway, it was was just an example - there're other stable IDE's - like f.e. Eclipse + CDT, but this is not the point here - You need an editor with a dependancy tracking, based on a variable symbol definitions - an IDE.
Regards.
Re: Setting up a C programming environment
On windows i have used Notepad++ , which i think is better than code::blocks and when i moved on Debian, this was one of the first things for which i've looked to see if there was ported version. Then i saw what i can do with a terminal and that was...
Take a look at this one:
https://atom.io/
I personally find it very useful. This editor with gcc in terminal is my recommendation, all you need is:
gcc [...] `pkg-config --cflags somelibrary` hello.c -o hello `pkg-config --libs somelibrary` [...]
Take a look at this one:
https://atom.io/
I personally find it very useful. This editor with gcc in terminal is my recommendation, all you need is:
gcc [...] `pkg-config --cflags somelibrary` hello.c -o hello `pkg-config --libs somelibrary` [...]
Re: Setting up a C programming environment
Nope, on winblows people are using notepad2-mod - if they need a simple but robust text editor.den4oman wrote:On windows i have used Notepad++
...
That's because Microshit wasn't able to develop even such a simple thing like a text editor for the last ~25 years. Their "notepad" is improperly using their own GDI interface - it is blinking like a crazy during window resizing - shame like hell.
Zero support for non-native encodings, fails even with standard ASCII (inability to display special characters) and slows down incredibly when the opened file has just few hundreds of kilobytes - do they really hiring software developers?
...
But, btw, it's only an example which is showing that Microshit is unable to create serious software - usually they are just stealing some solutions or (in much rarest cases) - buying particular solutions, and if this is not helping - they can always spread some kind of a FUD...
Bullshit - You have simply no idea what You're talking about.den4oman wrote:On windows i have used Notepad++ , which i think is better than code::blocks
This editor with gcc in terminal is my recommendation, all you need is:
gcc [...] `pkg-config --cflags somelibrary` hello.c -o hello `pkg-config --libs somelibrary` [...]
But what's worse - most likely You've never even launched the C::B - otherwise You would know about its excellent interfaces to GDB, GCC, !! linker !!, Valgrind, etc...
Odi profanum vulgus
Re: Setting up a C programming environment
tomazzi you're talking about this one https://notepad-plus-plus.org/ ,right?
On Windows i used it , so i can open every type of file, so i can't agree with u about encoding.
I have mistake - i used DevCpp , not Notepad++ for compiling and that was a really a long time ago - on middle High School level, so i'm sorry about talking like that about Code::Blocks. I can't give an abstract point of view. It is really good IDE and i recommend it too ...
What i wanted to say is that the Atom editor is really interesting - you didn't said anything about it.
And that gcc in terminal is what you should do - because it can give you a lot of useful skills. If you want to write in C , you'll probably want a low level of everything ... ( i think )
PS. Again sorry for the comment about Code::Blocks ...
PSS. The year was around 2009 when i last used Code::Blocks/DevCpp/Notepad++
On Windows i used it , so i can open every type of file, so i can't agree with u about encoding.
I have mistake - i used DevCpp , not Notepad++ for compiling and that was a really a long time ago - on middle High School level, so i'm sorry about talking like that about Code::Blocks. I can't give an abstract point of view. It is really good IDE and i recommend it too ...
What i wanted to say is that the Atom editor is really interesting - you didn't said anything about it.
And that gcc in terminal is what you should do - because it can give you a lot of useful skills. If you want to write in C , you'll probably want a low level of everything ... ( i think )
PS. Again sorry for the comment about Code::Blocks ...
PSS. The year was around 2009 when i last used Code::Blocks/DevCpp/Notepad++
- ralph.ronnquist
- Posts: 342
- Joined: 2015-12-19 01:07
- Location: Melbourne, Australia
- Been thanked: 6 times
Re: Setting up a C programming environment
@tomazzi: being right, or not, is not an excuse for being aggressive.
Re: Setting up a C programming environment
Do You mean this?ralph.ronnquist wrote:@tomazzi: being right, or not, is not an excuse for being aggressive.
Well, bullshits is bullshit, no matter how You are going to call it. Your definition of agression is apparently broken.Bullshit - You have simply no idea what You're talking about.
But what's worse - most likely You've never even launched the C::B (...)
No. Please read with understanding.den4oman wrote:tomazzi you're talking about this one https://notepad-plus-plus.org/ ,right?
On Windows i used it , so i can open every type of file, so i can't agree with u about encoding.
-----------------------------------
I don't know that editor. But it's not an IDE - therefore I'm not really interrested to try another tabbed editor clone, especially that all of them are based on the same solution: scintilla.den4oman wrote:What i wanted to say is that the Atom editor is really interesting - you didn't said anything about it.
List that "useful" skills please...den4oman wrote:And that gcc in terminal is what you should do - because it can give you a lot of useful skills. If you want to write in C , you'll probably want a low level of everything ... ( i think )
I can start with the first one:
An ability to stop yourself from crashing the monitor off the wall, after You realized that a little mistake requires partial recompilation of the project, and You need to write that long list of gcc and linker options again, without making another mistake
Odi profanum vulgus
Re: Setting up a C programming environment
@tomazzi
You are the one who need to read carefully, i'm talking about the one with the url i posted.... And i also wrote that it was a really long time ago ...
About the skills:
make mistake -> remember what cause it -> don't make it next time ; )
As i said
You are the one who need to read carefully, i'm talking about the one with the url i posted.... And i also wrote that it was a really long time ago ...
About the skills:
make mistake -> remember what cause it -> don't make it next time ; )
As i said
If you think gcc in terminal is useless ... please tell me what C programs you're making ?If you want to write in C , you'll probably want a low level of everything ... ( i think )
Re: Setting up a C programming environment
I was talking about Notepad, not Notepad++... never mind.den4oman wrote:@tomazzi
You are the one who need to read carefully, i'm talking about the one with the url i posted....
Yes, gcc used in teriminal by manually issuing all the options is next to useless - and definitely It won't teach You anything.den4oman wrote:If you think gcc in terminal is useless ...
Using of gcc in terminal can be good for a "hello world" or at a very early stage of learning, but otherwise it's just a waste of time, productivity and it'll be source of many, sometimes undetectable, errors (especially the order of linking of the object files)
*ALL* software projects in the world are using scripts which are in turn invoking gcc to compile the code.
The scripts are either generated by autotools or by IDEs or in a mixed way: the IDE can be used to configure autoconf/automake which in turn will create the final script.
This is how it works, no matter if it's EMACS, Code::Blocks, Eclipse or whatewer.
And to show You a sample, here is a set of commands needed to compile a relatively small program (exactly 5515 lines of code).
This is a debug mode, in which most of specialized gcc options is not used (to avoid confusing the debugger):
Code: Select all
gcc -Wall -pthread -Wextra -g -DDBG_LEVEL_0_off -DDBG_LEVEL_1 -DDBG_LEVEL_2 -c /home/tomazzi/ProgLinux/SLiMDCS/src/devices/mal.c -o target/obj/src/devices/mal.o
gcc -Wall -pthread -Wextra -g -DDBG_LEVEL_0_off -DDBG_LEVEL_1 -DDBG_LEVEL_2 -c /home/tomazzi/ProgLinux/SLiMDCS/src/devices/mal_cnv.c -o target/obj/src/devices/mal_cnv.o
gcc -Wall -pthread -Wextra -g -DDBG_LEVEL_0_off -DDBG_LEVEL_1 -DDBG_LEVEL_2 -c /home/tomazzi/ProgLinux/SLiMDCS/src/sdcs_HC/client_db.c -o target/obj/src/sdcs_HC/client_db.o
gcc -Wall -pthread -Wextra -g -DDBG_LEVEL_0_off -DDBG_LEVEL_1 -DDBG_LEVEL_2 -c /home/tomazzi/ProgLinux/SLiMDCS/src/sdcs_HC/daq_hc.c -o target/obj/src/sdcs_HC/daq_hc.o
gcc -Wall -pthread -Wextra -g -DDBG_LEVEL_0_off -DDBG_LEVEL_1 -DDBG_LEVEL_2 -c /home/tomazzi/ProgLinux/SLiMDCS/src/sdcs_HC/devcon_hc.c -o target/obj/src/sdcs_HC/devcon_hc.o
gcc -Wall -pthread -Wextra -g -DDBG_LEVEL_0_off -DDBG_LEVEL_1 -DDBG_LEVEL_2 -c /home/tomazzi/ProgLinux/SLiMDCS/src/sdcs_HC/hc_main.c -o target/obj/src/sdcs_HC/hc_main.o
gcc -Wall -pthread -Wextra -g -DDBG_LEVEL_0_off -DDBG_LEVEL_1 -DDBG_LEVEL_2 -c /home/tomazzi/ProgLinux/SLiMDCS/src/sdcs_HC/host.c -o target/obj/src/sdcs_HC/host.o
gcc -Wall -pthread -Wextra -g -DDBG_LEVEL_0_off -DDBG_LEVEL_1 -DDBG_LEVEL_2 -c /home/tomazzi/ProgLinux/SLiMDCS/src/shared/compstr.c -o target/obj/src/shared/compstr.o
gcc -Wall -pthread -Wextra -g -DDBG_LEVEL_0_off -DDBG_LEVEL_1 -DDBG_LEVEL_2 -c /home/tomazzi/ProgLinux/SLiMDCS/src/shared/connection.c -o target/obj/src/shared/connection.o
gcc -Wall -pthread -Wextra -g -DDBG_LEVEL_0_off -DDBG_LEVEL_1 -DDBG_LEVEL_2 -c /home/tomazzi/ProgLinux/SLiMDCS/src/shared/dynarr.c -o target/obj/src/shared/dynarr.o
gcc -Wall -pthread -Wextra -g -DDBG_LEVEL_0_off -DDBG_LEVEL_1 -DDBG_LEVEL_2 -c /home/tomazzi/ProgLinux/SLiMDCS/src/shared/iface.c -o target/obj/src/shared/iface.o
gcc -Wall -pthread -Wextra -g -DDBG_LEVEL_0_off -DDBG_LEVEL_1 -DDBG_LEVEL_2 -c /home/tomazzi/ProgLinux/SLiMDCS/src/shared/log.c -o target/obj/src/shared/log.o
gcc -Wall -pthread -Wextra -g -DDBG_LEVEL_0_off -DDBG_LEVEL_1 -DDBG_LEVEL_2 -c /home/tomazzi/ProgLinux/SLiMDCS/src/shared/protocol.c -o target/obj/src/shared/protocol.o
g++ -o target/sdcs_hc target/obj/src/devices/mal.o target/obj/src/devices/mal_cnv.o target/obj/src/sdcs_HC/client_db.o target/obj/src/sdcs_HC/daq_hc.o target/obj/src/sdcs_HC/devcon_hc.o target/obj/src/sdcs_HC/hc_main.o target/obj/src/sdcs_HC/host.o target/obj/src/shared/compstr.o target/obj/src/shared/connection.o target/obj/src/shared/dynarr.o target/obj/src/shared/iface.o target/obj/src/shared/log.o target/obj/src/shared/protocol.o -Wl,--hash-style=gnu -z relro -lrt -lcxc -ltxtconf
The above compiles a threading server, which is part of bigger project, but the code is not released yet. (I'll finish this in a month or two I think)den4oman wrote:... please tell me what C programs you're making ?
However, if You wish, You may take a look at the code of the cxc lib, which is one of the key components of the project.
Regards.
Odi profanum vulgus