Results 1 to 4 of 4

Thread: super rooki needs help with g++

  1. #1
    Join Date
    Nov 2012
    Beans
    16

    super rooki needs help with g++

    Ok i to a c++ class a LONGGGGGGGGGGGGGGGG time ago back around the turn of the cent. but i am wanting to get back into it via linux and i got g++ to not return any errors but it wont play it and i skimd the man g++ but i didn't see were it runs the file so... i need help how do i get GNU g++ to run the file???

  2. #2
    Join Date
    Apr 2009
    Location
    Germany
    Beans
    2,134
    Distro
    Ubuntu Development Release

    Re: super rooki needs help with g++

    by default it puts the result into a file named a.out, you run it with ./a.out (./ means current directory)
    you can change that with the -o option
    Code:
    g++ file.cpp -o result

  3. #3
    Join Date
    Nov 2012
    Beans
    16

    Re: super rooki needs help with g++

    Ok i am doing something wrong heres my term read out.

    • cw@cw:~/c++$ cd /
      cw@cw:/$ ls
      bin dev initrd.img lib32 media proc sbin sys var
      boot etc initrd.img.old lib64 mnt root selinux tmp vmlinuz
      cdrom home lib lost+found opt run srv usr vmlinuz.old
      cw@cw:/$ cd home
      cw@cw:/home$ ls
      cw
      cw@cw:/home$ cd /
      cw@cw:/$ /home/cw/c++/a.out
      bash: /home/cw/c++/a.out: No such file or directory
      cw@cw:/$ home/cw/c++/a.out
      bash: home/cw/c++/a.out: No such file or directory
      cw@cw:/$ cd /home/cw/c++
      cw@cw:~/c++$ a.out
      a.out: command not found
      cw@cw:~/c++$ g++ a.out
      g++: error: a.out: No such file or directory
      g++: fatal error: no input files
      compilation terminated.
      cw@cw:~/c++$ g++ m1st.cpp
      cw@cw:~/c++$ ls
      a.out m1st.cpp m1st.cpp~
      cw@cw:~/c++$

    What did i for get ????

  4. #4
    Join Date
    Nov 2012
    Beans
    16

    Re: super rooki needs help with g++

    Ok got it now thx i wasnt in the directory when i tryed running thx thx thx

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •