Error when compiling with Cygwin

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • TuPLaD

    Error when compiling with Cygwin

    Hello,
    I just made a little C++ console application:

    #include "iostream"
    using namespace std;

    int main ()
    {
    cout << "Hello Mars !";
    return 0;
    }

    But when i tryed to compile it with Cygwin.

    gcc main.cpp -o main.exe

    It gave me the following error:



    I heard there is some new *modern* c++ language ?!
  • Rolf Magnus

    #2
    Re: Error when compiling with Cygwin

    TuPLaD wrote:
    [color=blue]
    > Hello,
    > I just made a little C++ console application:
    >
    > #include "iostream"
    > using namespace std;
    >
    > int main ()
    > {
    > cout << "Hello Mars !";
    > return 0;
    > }
    >
    > But when i tryed to compile it with Cygwin.
    >
    > gcc main.cpp -o main.exe[/color]

    If you want to compile and link C++ code, use g++, not gcc. Since you
    seem to be using windows, the name might be different (AFAIK, Windows
    doesn't support '+' as part of file names).
    [color=blue]
    > It gave me the following error:
    >
    > http://users.pandora.be/rz6hkk/cygwin.png[/color]

    You made a screenshot of your compiler output!? Why not just paste it
    into the message?
    [color=blue]
    > I heard there is some new *modern* c++ language ?![/color]

    The last C++ standard version is from 2003, but except for a few minor
    corrections, it's the same as C++98.

    Comment

    • Sharad Kala

      #3
      Re: Error when compiling with Cygwin


      "Rolf Magnus" <ramagnus@t-online.de> wrote in message
      news:cgi1r1$p5a $05$1@news.t-online.com...[color=blue]
      > TuPLaD wrote:
      >[/color]
      [color=blue]
      > If you want to compile and link C++ code, use g++, not gcc. Since you
      > seem to be using windows, the name might be different (AFAIK, Windows
      > doesn't support '+' as part of file names).[/color]

      The name is g++ on Windows too.

      -Sharad


      Comment

      • Howard

        #4
        Re: Error when compiling with Cygwin


        "TuPLaD" <spawnxx@pandor a.be> wrote in message
        news:a2e43d1f.0 408250413.51d4c 3d3@posting.goo gle.com...[color=blue]
        > Hello,
        > I just made a little C++ console application:
        >
        > #include "iostream"
        > using namespace std;
        >
        > int main ()
        > {
        > cout << "Hello Mars !";
        > return 0;
        > }
        >
        > But when i tryed to compile it with Cygwin.
        >
        > gcc main.cpp -o main.exe
        >
        > It gave me the following error:
        >
        > http://users.pandora.be/rz6hkk/cygwin.png
        >[/color]
        No way am I clicking on a link like that...who knows what kind of virus I
        might download!

        If you've got a compiler error, either copy&paste it here, or at least tell
        us what it says.
        [color=blue]
        > I heard there is some new *modern* c++ language ?![/color]

        As opposed to what, the "ancient" C++ language? And what would it have to
        do with the problem? Surely no change has been made to C++ that would cause
        such simple code to fail when it used to work.

        (By the way, the usual method of including standard headers is to enclose
        the name in <> brackets, not "" quotes. I believe that using the brackets
        causes the compiler to search for those headers differently than when using
        quotes. No idea if that's your problem, though, because I don't know what
        error message you're getting.)

        -Howard







        Comment

        • Will Twentyman

          #5
          Re: Error when compiling with Cygwin

          TuPLaD wrote:
          [color=blue]
          > Hello,
          > I just made a little C++ console application:
          >
          > #include "iostream"[/color]

          This line should be: #include <iostream>
          [color=blue]
          > using namespace std;
          >
          > int main ()
          > {
          > cout << "Hello Mars !";
          > return 0;
          > }
          >
          > But when i tryed to compile it with Cygwin.
          >
          > gcc main.cpp -o main.exe
          >
          > It gave me the following error:
          >
          > http://users.pandora.be/rz6hkk/cygwin.png
          >
          > I heard there is some new *modern* c++ language ?![/color]


          --
          Will Twentyman
          email: wtwentyman at copper dot net

          Comment

          • Rich Grise

            #6
            Re: Error when compiling with Cygwin

            Rolf Magnus wrote:
            [color=blue]
            > TuPLaD wrote:
            >[color=green]
            >> Hello,
            >> I just made a little C++ console application:
            >>
            >> #include "iostream"
            >> using namespace std;
            >>
            >> int main ()
            >> {
            >> cout << "Hello Mars !";
            >> return 0;
            >> }
            >>
            >> But when i tryed to compile it with Cygwin.
            >>
            >> gcc main.cpp -o main.exe[/color]
            >
            > If you want to compile and link C++ code, use g++, not gcc. Since you
            > seem to be using windows, the name might be different (AFAIK, Windows
            > doesn't support '+' as part of file names).
            >[color=green]
            >> It gave me the following error:
            >>
            >> http://users.pandora.be/rz6hkk/cygwin.png[/color]
            >
            > You made a screenshot of your compiler output!? Why not just paste it
            > into the message?
            >[color=green]
            >> I heard there is some new *modern* c++ language ?![/color]
            >
            > The last C++ standard version is from 2003, but except for a few minor
            > corrections, it's the same as C++98.[/color]

            He can hit alt-prtsc, but he doesn't know how to copy/paste from a
            command prompt applet. I wonder if 2> works in cmd?

            Cheers!
            Rich

            Comment

            • Andre Heinen

              #7
              Re: Error when compiling with Cygwin

              On 25 Aug 2004 05:13:38 -0700, spawnxx@pandora .be (TuPLaD) wrote:[color=blue]
              >#include "iostream"[/color]

              I was about to post to tell the OP to use #include <iostream>
              instead of #include "iostream", but after I saw that neither Rolf
              nor Sharad reacted, I hesitated. I tried it, and indeed my
              compiler didn't complain. Yet I was under the impression that
              standard headers should be included with square brackets.

              Stroustrup 9.2.1 says that for standard headers square brackets
              should be used rather than quotes, but I couldn't figure out if
              it is mandatory or just some guideline.

              If I remember correctly, #include "somefile.h " means:
              1) first search for somefile.h in the current directory, and if
              that fails
              2) search the system directories.
              This would explain why my compiler accepted it.

              However, #include <iostream> does not mean that there must be a
              file called iostream: the name may be different, or there may be
              no file at all, depending on the compiler.

              Hence I believe that #include "iostream" may work on one
              compiler, but is not portable, and should be avoided.

              Did I miss something?

              --
              Andre Heinen
              My address is "a dot heinen at europeanlink dot com"

              Comment

              • jive

                #8
                Re: Error when compiling with Cygwin


                "Rich Grise" <null@example.n et> wrote in message
                news:ON5Xc.384$ yP4.275@trnddc0 8...[color=blue]
                >[color=green]
                > > The last C++ standard version is from 2003, but except for a few minor
                > > corrections, it's the same as C++98.[/color][/color]

                AFAIK there is only a draft, as the standardisation process is still
                incomplete and new revision of the C++ standard is supposedly due this fall.

                - jive


                Comment

                • Rolf Magnus

                  #9
                  Re: Error when compiling with Cygwin

                  jive wrote:
                  [color=blue]
                  >
                  > "Rich Grise" <null@example.n et> wrote in message
                  > news:ON5Xc.384$ yP4.275@trnddc0 8...[color=green]
                  >>[color=darkred]
                  >> > The last C++ standard version is from 2003, but except for a few
                  >> > minor corrections, it's the same as C++98.[/color][/color]
                  >
                  > AFAIK there is only a draft, as the standardisation process is still
                  > incomplete and new revision of the C++ standard is supposedly due this
                  > fall.[/color]

                  See:


                  Comment

                  • TuPLaD

                    #10
                    Re: Error when compiling with Cygwin

                    First of all ->
                    I didnt knew how to copy paste from Cygwin's window so i made a
                    screenshot
                    2) THERE DOESNT EXIST ANY ANY ANY ANY image virusses that can work
                    from a site, you will have to download & start it(yes it can go to
                    cache :]). So its not a virus.

                    Third -> I just compiled it in Linux, and it worked well :D
                    I started it, it gave me the text & stuff :]

                    Thx for your help all !

                    Comment

                    • Will Twentyman

                      #11
                      Re: Error when compiling with Cygwin

                      Andre Heinen wrote:
                      [color=blue]
                      > On 25 Aug 2004 05:13:38 -0700, spawnxx@pandora .be (TuPLaD) wrote:
                      >[color=green]
                      >>#include "iostream"[/color]
                      >
                      >
                      > I was about to post to tell the OP to use #include <iostream>
                      > instead of #include "iostream", but after I saw that neither Rolf
                      > nor Sharad reacted, I hesitated. I tried it, and indeed my
                      > compiler didn't complain. Yet I was under the impression that
                      > standard headers should be included with square brackets.
                      >
                      > Stroustrup 9.2.1 says that for standard headers square brackets
                      > should be used rather than quotes, but I couldn't figure out if
                      > it is mandatory or just some guideline.
                      >
                      > If I remember correctly, #include "somefile.h " means:
                      > 1) first search for somefile.h in the current directory, and if
                      > that fails
                      > 2) search the system directories.
                      > This would explain why my compiler accepted it.
                      >
                      > However, #include <iostream> does not mean that there must be a
                      > file called iostream: the name may be different, or there may be
                      > no file at all, depending on the compiler.
                      >
                      > Hence I believe that #include "iostream" may work on one
                      > compiler, but is not portable, and should be avoided.
                      >
                      > Did I miss something?[/color]

                      I think that if he used #include "iostream.h " it would work.

                      Based on the error messages, it looks like iostream didn't get loaded,
                      but the complaint from the compiler comes when he tries to use something
                      from iostream that hasn't loaded, specifically std::cout. I've gotten
                      similar types of errors in the past from this type of mistake,
                      especially when I mis-spell a filename.

                      --
                      Will Twentyman
                      email: wtwentyman at copper dot net

                      Comment

                      • Pete Chapman

                        #12
                        OT: Re: Error when compiling with Cygwin

                        TuPLaD wrote:[color=blue]
                        > 2) THERE DOESNT EXIST ANY ANY ANY ANY image virusses that can work
                        > from a site, you will have to download & start it(yes it can go to
                        > cache :]). So its not a virus.[/color]

                        Just FYI, it's quite possible have arbitrary code executed just by
                        loading an image. Take a look at:

                        That's just one (out-of-date) example. Granted, it's an exploit not a
                        virus. But there's no reason that you couldn't put a virus inside a BMP.

                        Comment

                        • Howard

                          #13
                          Re: Error when compiling with Cygwin


                          "TuPLaD" <spawnxx@pandor a.be> wrote in message
                          news:a2e43d1f.0 408260604.7e4f1 a73@posting.goo gle.com...[color=blue]
                          > First of all ->
                          > I didnt knew how to copy paste from Cygwin's window so i made a
                          > screenshot
                          > 2) THERE DOESNT EXIST ANY ANY ANY ANY image virusses that can work
                          > from a site, you will have to download & start it(yes it can go to
                          > cache :]). So its not a virus.
                          >[/color]

                          You obviously don't live in the MS Windows world! :-) Windows has been
                          well-known for allowing viruses in simply by clicking on a link. And the
                          link shown in the text doesn't always match the actual underlying link
                          (because HTML can hide it easily), so just because you have a .png extension
                          (whatever that is), doesn't mean it's not something that can execute when I
                          link to it. Check any of the dozen or more security notices about Windows
                          in the past year. I got a virus on my PC just a month or two ago, simply by
                          linking to a web site that had been compromised, and that was a site I
                          normally trust and have linked to many times! Basically, my philosophy
                          (like many Windows users') is to not click on links unless I know what I'm
                          linking to.
                          [color=blue]
                          > Third -> I just compiled it in Linux, and it worked well :D
                          > I started it, it gave me the text & stuff :]
                          >
                          > Thx for your help all ![/color]

                          (BTW, was it the include statement that was the problem?)


                          Comment

                          • Rolf Magnus

                            #14
                            Re: Error when compiling with Cygwin

                            TuPLaD wrote:
                            [color=blue]
                            > First of all ->
                            > I didnt knew how to copy paste from Cygwin's window so i made a
                            > screenshot[/color]

                            Fair enough, though unusual :-)
                            [color=blue]
                            > 2) THERE DOESNT EXIST ANY ANY ANY ANY image virusses that can work
                            > from a site, you will have to download & start it(yes it can go to
                            > cache :]). So its not a virus.[/color]

                            The fact that its name ends in .png alone doesn't mean it's just an
                            image. That depends on the mimetype that the http server sends. It
                            could easily be a html page with javascript and activex and (insert web
                            buzzword here).
                            [color=blue]
                            > Third -> I just compiled it in Linux, and it worked well :D[/color]

                            But surely not with the command line you wrote in your original message.
                            If you use gcc for it, the C++ standard library will not be linked in,
                            which should result (and does here on my linux box) in similar messages
                            to those from your screenshot.
                            Try (as I already wrote) g++ instead of gcc. Do you get the same errors
                            when using g++ under Cygwin?

                            Comment

                            • jive

                              #15
                              Re: Error when compiling with Cygwin

                              > "Rolf Magnus" <ramagnus@t-online.de> wrote in message news:cgk967$soo $00[color=blue]
                              > $1@news.t-online.com...
                              > jive wrote:
                              >[color=green]
                              > > The last C++ standard version is from 2003, but except for a few
                              > > minor corrections, it's the same as C++98.[/color]
                              >
                              > AFAIK there is only a draft, as the standardisation process is still
                              > incomplete and new revision of the C++ standard is supposedly due this
                              > fall.
                              >
                              > See:
                              > http://www.iso.org/iso/en/CatalogueD...talogueDetail?
                              > CSNUMBER=38110[/color]

                              Strange.. I found no mention about this on
                              http://www.open-std.org/jtc1/sc22/wg21/ and this
                              http://www.open-std.org/jtc1/sc22/wg...2004/n1638.pdf outdates
                              the one available on the ISO site.

                              Could someone comment on that?

                              - jive


                              ---
                              [ comp.std.c++ is moderated. To submit articles, try just posting with ]
                              [ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.e du ]
                              [ --- Please see the FAQ before posting. --- ]
                              [ FAQ: http://www.jamesd.demon.co.uk/csc/faq.html ]

                              Comment

                              Working...