How to start coding in Linux

Hello.
I've been into programing for some time, but nothing excessive, in fact, i'm still newbie with no experience. I've got some projects in my mind (some might be even useful for other ppl :P ) that will require a constant increasment of my knowledge and a lot of effort. Recently I've read 2 books pretty much explaining basics. I guess I got hold of "what coding is about". The main issue is, the books didn't really explain anything about tools. I find g++ a little hard to use. Well, basic compilation is simple, though there are a lot of options and things I find kinda hard. Is there anything 'easy' to get a basic info about it? (Found this http://gcc.gnu.org/onlinedocs/gcc-4.5.0/gcc/ , there's a LOT of info, is it good and worth reading? And do you know anything better?). Also I'd like some environment like DevC++ where I can write, compile, debug and test program in one window, would you mind recommending something?
In windows I made few "things" (that don't even deserve to be called programs), got some info about WinAPI, etc. In Linux its seriously different, process communicate with pipes and signals, well, as I don't know anything about it I can only say its a lot different. Looking for some tutorial again that would explain it. Especially about pipes, creating subproceses, dup2, time functions Found http://www.gnu.org/software/libc/manual/html_mono/libc.html
But yeah, its again a lot of things to read, and its not easily explained (after reading paragraphs about things previously mentioned I can barely find information about what I need) so what I'm asking for is some easier tutorials or tips.
After writing this post I realized my laziness, but I'm going to post it anyway hoping you'll spare me some of your kindness. Kk, going to lurk more.
If there was a bare minimum you needed to know about gcc, it would be:

1
2
3
4
5
6
-g          Compile with debugging information.
-W -Wall    Enable all Warnings.
-pedantic   Set compiler to strict iso C/C++ mode.
-o <file>   specify the name of the out file. 
-c          Do not run the linker. Causes the creation of .o[bject] files.
-l<lib>     Link library <lib>. 


Once you understand these things, you can probably learn the rest as you need it. The disadvantage here is that if you don't know something exists, you can't look for it...

You may wish to look into make. I'm sure a google search will turn up some tutorials on writing them. The manual is here:

http://www.gnu.org/software/make/manual/html_node/index.html
For starters you should get a decent IDE (such as Code::Blocks) and write a number of programs. In the process you'll have to look up how to do various things and will learn automatically.
I've tried eclipse. Well, we don't get along :)
Maybe I should try Code::Blocks?
Eclipse is said to create makefile automatically, as I'm writing plugin for xchat i need something like this:
g++ -Wl,--export-dynamic -Wall -O1 -shared -fPIC source.c -o plugin.so
And I don't know how to set it up there. There's also some other issues i don't like :<
With eclipse you have the option. You can use your own makefiles or let eclipse make them for you.

I use autotools to build my makefiles. Eclipse even has plugins to help with that. I tried Code::Blocks but the auto-complete was nowhere near as 'complete' as eclipse.

But its what you're happy with. Try different things and see what suites.

EDIT: Just to add, if you don't want eclipse to generate makefiles for you, go to project properties. Select C/C++ Build and uncheck "Generate makefiles automatically".
Last edited on
Code::Blocks also lets you write your own Makefiles. To be honest, though, I tend not to use an IDE. I feel more comfortable with a terminal window and a text editor.
closed account (1yR4jE8b)
I really like Netbeans for C/C++ development, it's the only IDE I can ever sit with and write out something worthwhile with. Otherwise it's good ol' Notepad++ and cmd.exe with tdm-mingw for me.
Otherwise it's good ol' Notepad++ and cmd.exe with tdm-mingw for me

The title of the thread is How to start coding in Linux
Thanks for your replies. I'm gonna read manuals on gnu.org and some more advanced books. And, well, practice :)
As for IDE Code::Blocks looks fine for me, its a lot more user friendly than eclipse. If there's anything you could add, please do :)
closed account (1yR4jE8b)
haha....forgot what board I was on

replace that with

gedit + gnome-terminal with whatever version of gcc is available for the distro I'm on.

I still advocate Netbeans as the Ultimate IDE though ;-P
The other thing is, do you actually have to know that low level unix stuff for what you are doing at the moment? If you are new to programming, then perhaps you don't want to just read through the lib C manual, though it would still be very helpful to have for reference; you will likely need to know bits and pieces from it eventually. It also might be easier to learn some of the concepts that you would read about in there outside of C, in bash. For instance, fifo's (I've not actually used them in C myself yet) might be better learnt from a tutorial that explains something like:

1
2
3
4
5
$ mkfifo named_pipe; cat named_pipe > file;

### different terminal ###

$ cat > named_pipe;

might be simpler than the C counterpart and help get the same concept across. Once you understand the concept reading how to do it in something like the lib C Manual should be a lot easier.

A quick google search returns things like:
http://www.linuxjournal.com/article/2156
http://bashcurescancer.com/more_named_pipes.html
I forgot to ask if lib _C_ is up to date, i mean, if there's no better lib for C++
short answer: There is no better library for C++. There are different ones, however. They are neither better nor worse, just different. Unless of course you have specific needs.

long answer: Basically lib C is the C language's basic library that goes through and is what you will want to use to do a lot of low level stuff. There are some things, for example stream manipulation (input and output), that is also done in other libraries (iostream) but it is higher level and does things differently. There are both pros and cons to this. I expect that the majority of the C standard library has higher level alternatives that you may prefer to use for various reasons. The C++ language itself has a lot of alternatives to things in C standard library, for instance error handling is done differently.

The other thing to be aware of is that if you are getting into *nix programming, then you are very likely going to be working with C libraries. I wouldn't expect there to be a C++ alternative library for all the functionality required, but I would expect there to be an alternate for most of it.

BTW, This site has decent documentation for some of the C standard library. You may find it easier to read than the lib c manual. It wont cover everything, but it is a good start and probably most of what you will need.
Last edited on
Topic archived. No new replies allowed.