• 0

g++ / gcc tutorials?


Question

Hi yah, folks!

I've recently turned into a Linux zealot. My first copy is Linux RedHat 6.1 (the kernel is 2.0 something...), but that's not too important, because as soon as I get my next check and buy some hardware, I'll be networking my home box to the Windows 98(with internet access) and then I'll be pretty much a member of the Linux "kernel of the month" club until I find one that suits me.

So, I'm sure people here can save me a lot of searching and recommend some good books/ online tutorials specifically aimed at Unix/Linux c++ and all it's myraid compilers. Mainly, I've been into C++ on Dos/Windows boxes. This won't be as hard a transition to make, I believe, because I've at least gotten some very simple programs to compile and run, but I keep running into unsupported functions (that are probably just moved to another header file and called something else, if past experience is any guide).

Also, I believe Bloodshed's Dev C++ might be worth the while here, too. I'll just have to re-download it, since I'm doing this Linux thing on a "new" hard drive.

Happy coding...

Hosiah

Link to comment
https://www.neowin.net/forum/topic/218946-g-gcc-tutorials/
Share on other sites

7 answers to this question

Recommended Posts

  • 0

You can use most libc/crt that you could use in windows (e.g., strcpy, printf, etc...). Just be careful of functions that use _. These are MS specific. You could also check out the POSIX docs. These allow multi-threading, and various other things you can't do with libc/crt.

http://www.cplusplus.com/ is a pretty good reference site. It may have tutorials but no idea really.

  • 0

This is only a bit off-topic, but why are you using RedHat 6.1? Newer distros will be a bit more current in technology (less that requires an update) and more useable.

Might as well add a bit of on-topic to this...

I found the following in a http://google.com/linux search.

  Quote
C

C Pointers

http://users.southeast.net/~garyg/ptrs/toc.html

C Introduction

http://www.scit.wlv.ac.uk/~jphb/cbook/html/

Increase C speed

http://www.ontek.com/mikey/current.html

http://www.lysator.liu.se/c/

About C Collections

http://pitel-lnx.ibk.fnt.hvu.nl/~rbergen/cmain.html

C resources for Beginners

http://www.sct.gu.edu.au/~anthony/tower/NE/C/

C Language complete ( makefile , libs etc )

http://www.pageplus.com/~hsf/libraries/com...ng/prog/c.shtml

Some C stuff ( Compilers tools , FAQ's )

http://www.sandybay.com/pc-web/C.htm

C Encylopedia

http://www.eskimo.com/~scs/cclass/cclass.html

C Classroom

http://www.cyberdiem.com/vin/learn.html

------------------------------------------------------------------------------------------

C++

C++ Material

http://www.icce.rug.nl/docs/cplusplus

http://www.cerfnet.com/~mpcline/c++-faq-lite/

http://cmwww.unn.ac.uk/~adrian/c++/cpppaper

http://www.desy.de/user/projects/C++/courses/cc/Tutorial

C++ tutorial

http://www.swcp.com/~dodrill/cppdoc/cpplist.htm

http://cs.sdsu.edu:8080/~whitney/courses/f...1/notes/index.h

http://www.itr.ch/courses/case/BoochReference/

http://www.icce.rug.nl/docs/cplusplus/cplusplus.html

Edited by markjensen
  • 0

I should start getting into Linux programming. I'm not a big fan of visual basic, but I'm always using it because that is what I know and it is what I need to get my job done. I feel like with every application I built on top of MS Office microsoft squeezes my balls a little more. Because if ever my company decides to drop office, all my applications are all of a sudden worthless.

I'll probably still code in visual basic for work (just because that is what they require). But if I had something outside of that, it might help me hold my sanity.

  • 0

Thank you all!

Yes, I found the man, info, and README's for gcc, g++, and have even been browsing some of the accessories like yacc (I think I'll just stick with writing C code, anyway!). Was just looking for books, etc. that specifically target C++ for Unix/Linux as opposed to Win/DOS platforms, perhaps even a brief synopsis of the chief ways they differ. However, example code from the Jamsa's Bible seems to compile so far (I'm working my way back through it for this)! So guess I won't have such a hard time adapting, anyway.

Sorry if I wasn't clearer...

And I'm using Redhat 6.1 just for temporary evaluation. Got it from a book at the public library (yes, the discs were still with the book and not damaged! Amazing!). Like I said (*or did I?), I'll be hooking up with more modern Linux versions only after I start my home network, because I have internet connection only to the Windows box (and I'm keeping it that way, let ->Windows<- deal with the outside world!), I have no CD burner, and a network cable makes more sense than an entire Linux distro cut into pieces and shuttled on some 150 floppy disks!

In any case, this was a no-risk, no-cost way to get an intermediate copy of Linux to bash on and decide if I wanted to go with it! I think of it as my "training wheels edition".

Anybody think I should tell the library to update their Linux books?

Hosiah

  • 0
  Quote
I should start getting into Linux programming. I'm not a big fan of visual basic, but I'm always using it because that is what I know and it is what I need to get my job done.

To nic:

Well, see, here's an example of what I'm talking about, but in a different context. If you want to branch out into Linux/C++ from Microsoft Visual Basic, here are some chief differences I think you'll find:

(I have experience with BASIC only in the old GW-BASIC, QBasic, and up to QB-4.5, before going to C, so forgive me if some of my assumptions about how VB is are incorrect) anybody can correct me, I'll be fine with it!

Header files: C actually has very few commands included with the language. Most of the functions you'll be using require header files to be included. Really not much different from library functions, but in C, you *have* to use them to get anything useful done.

Functions: In Basic, I presume you still have a main body of the program, subroutines, and functions. In C, everything is a function! Even the main body is just a function called "main".

Punctuation syntax: Almost all the punctuation characters mean something different. You'll forget to end each statement with a semi-colon a few times, before you get it right.

Briefer code: In BASIC, I remember having to type a lot more than I have to in C to accomplish the same thing. C can combine several statements into one compact, cryptic statement. Like so:

if (foo(++i))

this will (a) increment variable i by one, (b) plug it into function foo, and © evaluate the output of foo for true or false. Even if the "if"'s condition is not met, variable i remains incremented! I know of no similar stunts you can pull in Basic.

By the way, if you want to test for a specific value:

if(foo(i)==42)

will evaluate, while using a single '=' in the same place will put 42 in the variable foo no matter what! Using double '==' signs in C where you used a single '=' in Basic for evaluation will be another 'gotcha!'

Variables: No more creating and initializing variables "on the fly". All variables have to be declared (called "casting") before use. Also, get used to data types that are more flexible. For instance:

int i;
char foo[256]="This is a string.";

i=foo[1];

is legal C! Yes, you can put a character in an integer, which can then be turned around and used like a number.

String functions: C doesn't allow you to say things like "bar$=baz$". Instead, you would use functions like "strcpy()" which would usually require the inclusion of "string.h" in header files. At least one book, "C++ in Plain English" by Brian Overland, has a chapter focusing on creating C string functions which mimic Basic string functions.

The Linux programming environment: Kiss the bloated, over-featured, slow-as-molases interface a fond goodbye! In Linux, you can write, compile, and test simple programs all from the command line. To wit, using emacs text editor, hitting "Ctrl-x Ctrl-s" to save it (name it foo.c), exit emacs (Ctrl-x Ctrl-c), type "gcc -o foo foo.c" at the command line, read the errors and warnings as they pop up at the prompt, and if all went well, execute the program with "/mydirectory/foo" for instance. Edit further by typing "emacs foo.c" again. It speeds up the process immensely!

That's just what I can think of off the top of my head, for going from Basic to C. Now, I'm back to researching the differences between Windows and Linux. I know that I can forget about "WinMain" functions and using files by a path of "C:\Foo\Bar.dat" , because in Linux it's in directory "/usr/programs/Bar.dat". I know that I can't do console graphics by including "wincgi.h" anymore. But the rest is still fog. I'll have to research it all as it comes up, one issue at a time. For instance, I know the "curses.h" headers and libraries have something to do with using character graphics on the screen, but none of the C books I have even mention curses.

I'll probably write THAT article in my blog (after I've achieved the knowledge!).

Hosiah the hoser

This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.