novice question, linking error in "hello, world!" program


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 9 of 9

Thread: novice question, linking error in "hello, world!" program

Hybrid View

  1. #1
    MC Guest

    novice question, linking error in "hello, world!" program


    When I tried the following code in VC++ SP4

    #include <iostream>

    void main(int argc, char* argv[])
    {
    // printf("Hello World!\n");
    cout << "hello world!" << endl ;
    }

    I got the following error,
    c:\temp\del\del.cpp(13) : fatal error C1010: unexpected end of file while
    looking for precompiled header directive

    What did I do wrong? Please help! Thanks!

  2. #2
    eejay Guest

    Re: novice question, linking error in "hello, world!" program


    Since you not use namespace your header file should be iostream.h instead
    of iostream. Then it should compile fine.

    eejay

    "MC" <visualtest@yahoo.com> wrote:
    >
    >When I tried the following code in VC++ SP4
    >
    >#include <iostream>
    >
    >void main(int argc, char* argv[])
    >{
    >// printf("Hello World!\n");
    > cout << "hello world!" << endl ;
    >}
    >
    >I got the following error,
    >c:\temp\del\del.cpp(13) : fatal error C1010: unexpected end of file while
    >looking for precompiled header directive
    >
    >What did I do wrong? Please help! Thanks!



  3. #3
    MC Guest

    Re: novice question, linking error in "hello, world!" program


    I tried to use both <iostream.h> or <iostream> without namespace, but I still
    got the same error.

    I also tried the following:-
    -Rebuild all
    -Build
    -Compile
    -Run

    The error is the same. I suspect I got some settings wrong but I can't figure
    it out. Any clue? Thanks!

    "eejay" <enickols@midsouth.rr.com> wrote:
    >
    >Since you not use namespace your header file should be iostream.h instead
    >of iostream. Then it should compile fine.
    >
    >eejay
    >
    >"MC" <visualtest@yahoo.com> wrote:
    >>
    >>When I tried the following code in VC++ SP4
    >>
    >>#include <iostream>
    >>
    >>void main(int argc, char* argv[])
    >>{
    >>// printf("Hello World!\n");
    >> cout << "hello world!" << endl ;
    >>}
    >>
    >>I got the following error,
    >>c:\temp\del\del.cpp(13) : fatal error C1010: unexpected end of file while
    >>looking for precompiled header directive
    >>
    >>What did I do wrong? Please help! Thanks!

    >



  4. #4
    krumin Guest

    Re: novice question, linking error in "hello, world!" program


    If you are using Visual Studio which type of project did you use?
    Be sure that you specify console application.

    krumin
    "MC" <visualtest@yahoo.com> wrote:
    >
    >I tried to use both <iostream.h> or <iostream> without namespace, but I

    still
    >got the same error.
    >
    >I also tried the following:-
    >-Rebuild all
    >-Build
    >-Compile
    >-Run
    >
    >The error is the same. I suspect I got some settings wrong but I can't figure
    >it out. Any clue? Thanks!
    >
    >"eejay" <enickols@midsouth.rr.com> wrote:
    >>
    >>Since you not use namespace your header file should be iostream.h instead
    >>of iostream. Then it should compile fine.
    >>
    >>eejay
    >>
    >>"MC" <visualtest@yahoo.com> wrote:
    >>>
    >>>When I tried the following code in VC++ SP4
    >>>
    >>>#include <iostream>
    >>>
    >>>void main(int argc, char* argv[])
    >>>{
    >>>// printf("Hello World!\n");
    >>> cout << "hello world!" << endl ;
    >>>}
    >>>
    >>>I got the following error,
    >>>c:\temp\del\del.cpp(13) : fatal error C1010: unexpected end of file while
    >>>looking for precompiled header directive
    >>>
    >>>What did I do wrong? Please help! Thanks!

    >>

    >



  5. #5
    krumin Guest

    Re: novice question, linking error in "hello, world!" program


    Also check what directories for include files are specified in Tools...Options...Directories.

    krumin
    "MC" <visualtest@yahoo.com> wrote:
    >
    >I tried to use both <iostream.h> or <iostream> without namespace, but I

    still
    >got the same error.
    >
    >I also tried the following:-
    >-Rebuild all
    >-Build
    >-Compile
    >-Run
    >
    >The error is the same. I suspect I got some settings wrong but I can't figure
    >it out. Any clue? Thanks!
    >
    >"eejay" <enickols@midsouth.rr.com> wrote:
    >>
    >>Since you not use namespace your header file should be iostream.h instead
    >>of iostream. Then it should compile fine.
    >>
    >>eejay
    >>
    >>"MC" <visualtest@yahoo.com> wrote:
    >>>
    >>>When I tried the following code in VC++ SP4
    >>>
    >>>#include <iostream>
    >>>
    >>>void main(int argc, char* argv[])
    >>>{
    >>>// printf("Hello World!\n");
    >>> cout << "hello world!" << endl ;
    >>>}
    >>>
    >>>I got the following error,
    >>>c:\temp\del\del.cpp(13) : fatal error C1010: unexpected end of file while
    >>>looking for precompiled header directive
    >>>
    >>>What did I do wrong? Please help! Thanks!

    >>

    >



  6. #6
    simon Guest

    Re: novice question, linking error in "hello, world!" program

    I copied your code and ran it on VC++, it ran okay after I changed the
    header to <isotream.h>. And if you are NOT using VC++, don't forget to add
    the "using namespace::std" line. Many compilers don't use the .h libraries.

    simon.



    "MC" <visualtest@yahoo.com> wrote in message
    news:3a9eba8c$1@news.devx.com...
    >
    > I tried to use both <iostream.h> or <iostream> without namespace, but I

    still
    > got the same error.
    >
    > I also tried the following:-
    > -Rebuild all
    > -Build
    > -Compile
    > -Run
    >
    > The error is the same. I suspect I got some settings wrong but I can't

    figure
    > it out. Any clue? Thanks!
    >
    > "eejay" <enickols@midsouth.rr.com> wrote:
    > >
    > >Since you not use namespace your header file should be iostream.h instead
    > >of iostream. Then it should compile fine.
    > >
    > >eejay
    > >
    > >"MC" <visualtest@yahoo.com> wrote:
    > >>
    > >>When I tried the following code in VC++ SP4
    > >>
    > >>#include <iostream>
    > >>
    > >>void main(int argc, char* argv[])
    > >>{
    > >>// printf("Hello World!\n");
    > >> cout << "hello world!" << endl ;
    > >>}
    > >>
    > >>I got the following error,
    > >>c:\temp\del\del.cpp(13) : fatal error C1010: unexpected end of file

    while
    > >>looking for precompiled header directive
    > >>
    > >>What did I do wrong? Please help! Thanks!

    > >

    >



  7. #7
    Danny Kalev Guest

    Re: novice question, linking error in "hello, world!" program



    simon wrote:
    >
    > I copied your code and ran it on VC++, it ran okay after I changed the
    > header to <isotream.h>. And if you are NOT using VC++, don't forget to add
    > the "using namespace::std" line. Many compilers don't use the .h libraries.


    Actually, VC++ 6 does support the <iostream> library. A using
    declaration or using directive is required in this case, but the
    original poster's problem seems to have been caused by incorrect project
    setting.

    Danny

  8. #8
    MC Guest

    Re: novice question, linking error in "hello, world!" program


    Finally, I found the cause, it's because the default Win32 console app. template
    set the precompiled header file to "stdafx.h" but I didn't know that. Once
    I set <iostream> include file in "stdafx.h" and recompile it. It works.

    However, that make me have another question, what is the real benefit to
    have a precompiled header file? Would that make a build process faster?


    "krumin" <krumin620244@aol.com> wrote:
    >
    >Also check what directories for include files are specified in Tools...Options...Directories.
    >
    >krumin
    >"MC" <visualtest@yahoo.com> wrote:
    >>
    >>I tried to use both <iostream.h> or <iostream> without namespace, but I

    >still
    >>got the same error.
    >>
    >>I also tried the following:-
    >>-Rebuild all
    >>-Build
    >>-Compile
    >>-Run
    >>
    >>The error is the same. I suspect I got some settings wrong but I can't

    figure
    >>it out. Any clue? Thanks!
    >>
    >>"eejay" <enickols@midsouth.rr.com> wrote:
    >>>
    >>>Since you not use namespace your header file should be iostream.h instead
    >>>of iostream. Then it should compile fine.
    >>>
    >>>eejay
    >>>
    >>>"MC" <visualtest@yahoo.com> wrote:
    >>>>
    >>>>When I tried the following code in VC++ SP4
    >>>>
    >>>>#include <iostream>
    >>>>
    >>>>void main(int argc, char* argv[])
    >>>>{
    >>>>// printf("Hello World!\n");
    >>>> cout << "hello world!" << endl ;
    >>>>}
    >>>>
    >>>>I got the following error,
    >>>>c:\temp\del\del.cpp(13) : fatal error C1010: unexpected end of file while
    >>>>looking for precompiled header directive
    >>>>
    >>>>What did I do wrong? Please help! Thanks!
    >>>

    >>

    >



  9. #9
    Danny Kalev Guest

    Re: novice question, linking error in "hello, world!" program



    MC wrote:
    >
    > Finally, I found the cause, it's because the default Win32 console app. template
    > set the precompiled header file to "stdafx.h" but I didn't know that. Once
    > I set <iostream> include file in "stdafx.h" and recompile it. It works.
    >
    > However, that make me have another question, what is the real benefit to
    > have a precompiled header file? Would that make a build process faster?


    yes, it reduces the total build time, especially in large projects.
    However, it my cause other problems, as you have experienced...

    Danny

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center