Page 1 of 2 12 LastLast
Results 1 to 10 of 11

Thread: Geany C++ HELP!!

  1. #1
    Join Date
    Sep 2006
    Beans
    5

    Geany C++ HELP!!

    Hi, I just recently started to use Geany. Previously using Bloodshed Dev-C++ and love it.
    When I was trying it out with a "Hello World" printf statement. My compiler gives me an error. Can someone help me out?

    Here's my code:

    #include <stdio.h>
    #include <stdlib.h>
    #include <conio.h>
    main()
    {
    printf("Hello World");
    system("pause");
    }


    This is the error I get:

    gcc -Wall -c "untitled" (in directory: /home/ch0p5t1ckb01)
    gcc: untitled: linker input file unused because linking not done
    Compilation finished successfully.

    Does not allow me to execute the file.

    Any help is greatly appreciated!!
    Last edited by Ch0p5t1ckB01; April 9th, 2007 at 06:13 PM.

  2. #2
    Join Date
    Apr 2007
    Location
    Buenos Aires - Argentina
    Beans
    43
    Distro
    Ubuntu 7.04 Feisty Fawn

    Re: Geany C++ HELP!!

    Quote Originally Posted by Ch0p5t1ckB01 View Post
    Does not allow me to execute the file.
    Because you're providing the 'compile only' option to the compiler. Try doing this:

    Code:
    gcc -Wall untitled
    Please note the fact that this option '-c' is missing.

    Quote Originally Posted by Ch0p5t1ckB01 View Post
    main()
    {
    printf("Hello World");
    system("pause");
    }
    Try to declare your main function this way:

    Code:
    int main (int, char **) or int main (int, char*[])
    Both arguments and the return type are important.

    Quote Originally Posted by Ch0p5t1ckB01 View Post
    system("pause");
    If you're planning to execute this application in Linux try to remove that line. 'Pause' is a Microsoft DOS command not a one supported in Bash.

    Regards.
    Free software, free society. - Richard M. Stallman.

  3. #3
    Join Date
    Mar 2006
    Location
    Philadelphia, PA
    Beans
    470

    Re: Geany C++ HELP!!

    Um acutally its just because you didnt save the file before hand. You might want to use:
    Code:
    system("sleep 1");
    for a replacement to the PAUSE command in dos.
    Ubuntu User #: 0x2695 | Banshee 1.8/2.0 Pidgin Plugin

    Intel Q6600 @3.21, 4GB, GTX260, ArchLinux
    Lenovo IdeaPad S10, 1.6GHz Intel Atom, ArchLinux

  4. #4
    Join Date
    Dec 2006
    Location
    Australia
    Beans
    1,097
    Distro
    Ubuntu 12.04 Precise Pangolin

    Re: Geany C++ HELP!!

    Or else use getchar() instead of system("whatever").

    With getchar() you just have to press a key, so you can stare at the greeting and feel really good for as long as you want.

  5. #5
    Join Date
    Jan 2006
    Beans
    Hidden!
    Distro
    Ubuntu 10.10 Maverick Meerkat

    Re: Geany C++ HELP!!

    press F9 to actually build the file (where it also links), F8 only compiles (to check for syntax errors)

    and remove that system()/getcahr() nonsense, if you have latest geany it will put in appropriate wrapper code to keep the shell open.

  6. #6
    Join Date
    Jul 2008
    Beans
    7
    Distro
    Xubuntu

    Re: Geany C++ HELP!!

    Wow, Slavik. I also had the same problem. Your solution works quick. Ha ha ha. I feel foolish for making such a small error.

  7. #7
    Join Date
    Jan 2009
    Location
    Arizona, US
    Beans
    113
    Distro
    Ubuntu 9.10 Karmic Koala

    Re: Geany C++ HELP!!

    PLEASE don't ever use system()

  8. #8
    Join Date
    Oct 2007
    Beans
    1,914
    Distro
    Lubuntu 12.10 Quantal Quetzal

    Re: Geany C++ HELP!!

    Quote Originally Posted by efeXor View Post
    PLEASE don't ever use system()
    Reason?

  9. #9
    Join Date
    Nov 2007
    Beans
    706
    Distro
    Ubuntu 9.04 Jaunty Jackalope

    Re: Geany C++ HELP!!

    Quote Originally Posted by Zugzwang View Post
    Reason?
    Not cross-platform and relies too much on the outside world. Trivial and irrelevant for this situation, but foolish to use in a larger program where there's an alternative.
    Programming is an art. Learn it. Live it. Love it.

  10. #10
    Join Date
    Jan 2009
    Beans
    11

    Re: Geany C++ HELP!!

    Quote Originally Posted by Sinkingships7 View Post
    Not cross-platform and relies too much on the outside world. Trivial and irrelevant for this situation, but foolish to use in a larger program where there's an alternative.
    Try this instead:
    Code:
    cout << "Press enter to continue..";
    cin.get();

Page 1 of 2 12 LastLast

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
  •