Gcc?

This is a discussion on Gcc? within the Linux Programming forums, part of the Platform Specific Boards category; If I install RedHat 7.0 and actually get the thing working, how do I start using gcc? How do I ...

  1. #1
    Anti-Terrorist
    Join Date
    Aug 2001
    Location
    mming, Game DevelopmentCSR >&<>&2Minimization of boolean functions, PROM,PLA design >&0>&WA, USA guitar, dogsCommercial Aviation >&>>&USAProgramming
    Posts
    742

    Gcc?

    If I install RedHat 7.0 and actually get the thing working, how do I start using gcc? How do I activate the editor, what is the name of the editor? And what are the commands to first compile and build my executable? What are the steps to creating a program after all the code is written? Do I need to create a make file? Is this done on the command line? Is the whole process a really big pain?
    I compile code with:
    Visual Studio.NET beta2

  2. #2
    Blank
    Join Date
    Aug 2001
    Posts
    1,034
    I use emacs and I have something like

    Code:
    (setq auto-mode-alist
          (append '(("\\.C$"  . c++-mode)
                    ("\\.cc$" . c++-mode)
                    ("\\.cpp$" . c++-mode)
                    ("\\.h$"  . c++-mode)
                    ("\\.hh$" . c++-mode)
                    ("\\.idl$". c++-mode)
                    ("\\.c$"  . c-mode))
                        auto-mode-alist))
    
    (add-hook 'c-mode-common-hook
              '(lambda ()
                 (setq indent-tabs-mode nil)
                 (c-set-style "stroustrup")))
    
    (global-font-lock-mode t)
    (lazy-lock-mode t)
    in my ~/.emacs

    If just compiling one file you can do something like
    g++ foo.cc -Wall for c++

  3. #3
    Unregistered
    Guest
    Or just use a visual IDE with gcc, like KDevelop or whatever (there are many). Then it is just like it is in Windows.

  4. #4
    Registered User
    Join Date
    Aug 2001
    Posts
    79
    how do I start using gcc?
    $gcc inputfile.c -o executablename -lstdc++

    $ represents a command prompt. Some people use % instead
    How do I activate the editor, what is the name of the editor?
    There are two popular editors, and a few less popular editors. The two most popular ones are vi and emacs.

    vi~=notepad
    emacs~=Word, but that uses primarily plaintext

    "$vi name" creates name if name does not exist. RH7's vi is a symlink to vim, which is slightly different."$emacs name" creates name if name does not exist. Emacs is primarily an X application(read: windows program), whereas vi is more of a console program(read: dos program).
    And what are the commands to first compile and build my executable?
    "$gcc inputfilename -o executablename -llibraryname" builds inputfilename into an executable called executablename using the library libraryname, where libraryname is found in /usr/lib/liblibraryname.so, or /lib/liblibraryname.so
    What are the steps to creating a program after all the code is written?
    Just gcc it. Gcc commandlines can get pretty hairy for anything more than a simple test program. To make it easier, make and makefiles were invented. I don't know anything about using makefiles.
    Do I need to create a make file?
    No, but for larger programs you will want to eventually.
    Is this done on the command line? Is the whole process a really big pain?
    Yes it's all done on the command line if you separate the editor from the compiler, which emacs does not do. There's an emacs mode that gives you a shortcut key to compile the current file, and other such things. It's not a big pain. People do it all the time. The overhead of a makefile is a one-time thing, and really speeds up the project once done. autoconf and automake make the overhead even less per project, but there's a one-time overhead in learning how to use them, which isn't trivial.(You could probably learn it in 24 hours or so if you had some projects for which you need to make some makefiles, but I don't, so learning on a purely abstract basis is rather difficult)
    All generalizations are false

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Profiler Valgrind
    By afflictedd2 in forum C++ Programming
    Replies: 4
    Last Post: 07-18-2008, 10:38 AM
  2. Replies: 4
    Last Post: 09-02-2007, 09:47 PM
  3. segfault with gcc, but not with TC
    By koodoo in forum C Programming
    Replies: 15
    Last Post: 04-23-2007, 10:08 AM
  4. Compiles on gcc 3.3 but not on gcc 4.0.3
    By cunnus88 in forum C++ Programming
    Replies: 5
    Last Post: 03-29-2007, 01:24 PM
  5. gcc
    By DavidP in forum A Brief History of Cprogramming.com
    Replies: 21
    Last Post: 10-22-2003, 04:46 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21