Thread: writting programs on linux

  1. #1
    Registered User Micko's Avatar
    Join Date
    Nov 2003
    Posts
    715

    writting programs on linux

    Hello, guys, today I've installed linux mandrake 9.0 I want to write my first line of code under linux platform. Since i don't know anything about linux I cannot find gcc compiler on it. Can you suggest any good IDE with compiler (C/C++) which I can download and install on linux system?
    Thanks
    Last edited by Micko; 11-25-2005 at 02:56 AM.
    Gotta love the "please fix this for me, but I'm not going to tell you which functions we're allowed to use" posts.
    It's like teaching people to walk by first breaking their legs - muppet teachers! - Salem

  2. #2
    ... kermit's Avatar
    Join Date
    Jan 2003
    Posts
    1,534
    I would imagine that gcc is installed already - you could find out by doing:

    whereis gcc

    or

    gcc -v

    Anyway, if you did not install it, go back to your install disc and do it that way. As for an IDE, try KDevelop - you might have some troubles though, with your libraries being ancient (Mandrake 9 is quite old now). Personally, I think Emacs makes a nice IDE, though I know some would not agree with me on that one...

    If you are not in to messing around with makefiles, you could just type in your source to a text editor of your choice, and then invoke the compiler from the command line, something like so:

    gcc -Wall -o your_prog your_prog.c

    This tells gcc to crank up the warnings (Wall) and call your program your_prog (If you don't use -o name then your executable file will be called 'a.out' by default). If you want to run the program through gdb, then use the -ggdb option as well.

  3. #3
    Registered User Micko's Avatar
    Join Date
    Nov 2003
    Posts
    715
    Thanks,
    i have found gcc.
    Now my problem is how to use it to get .exe file. For example I have source code file named Prvi.c

    I tried "gcc Prvi.c" but all I get is a.out, and that I cannot run.
    I installed linux yesterday and have no prior experience...
    Thanks
    Gotta love the "please fix this for me, but I'm not going to tell you which functions we're allowed to use" posts.
    It's like teaching people to walk by first breaking their legs - muppet teachers! - Salem

  4. #4
    C(++)(#)
    Join Date
    Jul 2004
    Posts
    309
    To get a specific file:

    gcc Prvi.c -o Prvi

    then to run it just change directories to where the file Prvi is and then type in ./Prvi at the console.
    To code is divine

  5. #5
    Registered User Micko's Avatar
    Join Date
    Nov 2003
    Posts
    715
    Thanks, that was exactly what I wanted...
    Gotta love the "please fix this for me, but I'm not going to tell you which functions we're allowed to use" posts.
    It's like teaching people to walk by first breaking their legs - muppet teachers! - Salem

  6. #6
    Frequently Quite Prolix dwks's Avatar
    Join Date
    Apr 2005
    Location
    Canada
    Posts
    8,057
    I tried "gcc Prvi.c" but all I get is a.out, and that I cannot run.
    I thought so too, for a while. But you can:
    Code:
    $ ./a.out
    dwk

    Seek and ye shall find. quaere et invenies.

    "Simplicity does not precede complexity, but follows it." -- Alan Perlis
    "Testing can only prove the presence of bugs, not their absence." -- Edsger Dijkstra
    "The only real mistake is the one from which we learn nothing." -- John Powell


    Other boards: DaniWeb, TPS
    Unofficial Wiki FAQ: cpwiki.sf.net

    My website: http://dwks.theprogrammingsite.com/
    Projects: codeform, xuni, atlantis, nort, etc.

  7. #7
    Registered User Micko's Avatar
    Join Date
    Nov 2003
    Posts
    715
    Yes, I know now, "./" was key to solving my problem
    Gotta love the "please fix this for me, but I'm not going to tell you which functions we're allowed to use" posts.
    It's like teaching people to walk by first breaking their legs - muppet teachers! - Salem

  8. #8
    Registered User
    Join Date
    Feb 2005
    Posts
    38
    "./" solves everybody's problems.
    I like to play pocket pool.

  9. #9
    Registered User
    Join Date
    Jun 2005
    Location
    Stockholm, Sweden
    Posts
    64
    Code:
    tomas@loke:~$ ./end world hunger
    -bash: ./end: No such file or directory
    Nope

  10. #10
    C++ Enthusiast jmd15's Avatar
    Join Date
    Mar 2005
    Location
    MI
    Posts
    532
    When I compile, in Knoppix, I use this command:
    Code:
    g++ -Wall input.cpp -o output
    Then I can just type output and it will run. However, if I specify an extension(output.out) then I have to use the ./ command. It seems easier and better, at least to me, to leave off an extension so you can just type the name and it will run.
    Trinity: "Neo... nobody has ever done this before."
    Neo: "That's why it's going to work."
    c9915ec6c1f3b876ddf38514adbb94f0

  11. #11
    aoeuhtns
    Join Date
    Jul 2005
    Posts
    581
    Quote Originally Posted by jmd15
    When I compile, in Knoppix, I use this command:
    Code:
    g++ -Wall input.cpp -o output
    Then I can just type output and it will run. However, if I specify an extension(output.out) then I have to use the ./ command. It seems easier and better, at least to me, to leave off an extension so you can just type the name and it will run.
    Unfortunately (or, if you ask me, fortunately), this is not true of (all) other Linux and Unix distributions.

  12. #12
    Sys.os_type="Unix";;
    Join Date
    Aug 2005
    Posts
    52
    Quote Originally Posted by jmd15
    When I compile, in Knoppix, I use this command:
    Code:
    g++ -Wall input.cpp -o output
    Then I can just type output and it will run. However, if I specify an extension(output.out) then I have to use the ./ command. It seems easier and better, at least to me, to leave off an extension so you can just type the name and it will run.
    ./ is not a command it's merely specifying the path of the target you want to reach.

    If whatever directory you're currently in isn't specified in the PATH environment variable it won't find it when searching for that executable and you will be required to specify a ./ to signify that it's in your current working directory.

    Since CWD is .
    And the previous folder is ..
    If you want you can add . to the PATH

    Code:
    # uname -a
    QNX 1 H 425 PCI 32
    # echo $PATH
    /bin:/etc:/usr/bin:/etc:/usr/ucb:/usr/local/bin:/qnx4/photon/bin:/usr/bin/photon/
    # PATH=$PATH:.
    # echo $PATH
    /bin:/etc:/usr/bin:/etc:/usr/ucb:/usr/local/bin:/qnx4/photon/bin:/usr/bin/photon/:.
    Now it will also search for the executable I'm trying to run from whichever CWD I'm in at the time(as long as it can't find it in any of the other folders in the PATH first since . is at the end)
    You may also need to specify 'export PATH=$PATH:.' depends on what you're running.

  13. #13
    Registered User Jaqui's Avatar
    Join Date
    Feb 2005
    Posts
    416
    Mandrake ( now Mandriva ) has released their 2006 edition, this, under old numbering system is version 11.0..at 6 months between releases 9.0 is 4 years old.
    most linux distros release at least once a year, unlike ms every 5 years.

    I do use an even older version of linux, as the one commercially licensed development tool I have requires the 2.4 kernel toolchain.
    Quote Originally Posted by Jeff Henager
    If the average user can put a CD in and boot the system and follow the prompts, he can install and use Linux. If he can't do that simple task, he doesn't need to be around technology.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Linux Version reccomendation
    By Pobega in forum A Brief History of Cprogramming.com
    Replies: 28
    Last Post: 10-05-2006, 06:48 PM
  2. Why Linux, for the average user?
    By Hunter2 in forum A Brief History of Cprogramming.com
    Replies: 32
    Last Post: 07-07-2006, 02:36 PM
  3. Linux Linux why Linux??
    By afreedboy in forum Tech Board
    Replies: 146
    Last Post: 01-21-2004, 06:27 PM
  4. Text Editor (RH Linux)
    By LittleJohn in forum C Programming
    Replies: 10
    Last Post: 12-15-2003, 03:41 AM
  5. linux vs linux?
    By Dreamerv3 in forum Linux Programming
    Replies: 5
    Last Post: 01-22-2002, 09:39 AM