Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: Can't compile example program with VC2010!  (Read 5827 times)

0 Members and 1 Guest are viewing this topic.

Aerosol

  • Newbie
  • *
  • Posts: 5
    • View Profile
Can't compile example program with VC2010!
« on: September 14, 2010, 09:24:00 pm »
Hey all. I can't build the "compile your first SFML program" code in VC2010. First time I tried to build, I got this error:

Code: [Select]
1>------ Build started: Project: SFML_1, Configuration: Debug Win32 ------
1>Build started 9/14/2010 3:20:35 PM.
1>InitializeBuildStatus:
1>  Touching "Debug\SFML_1.unsuccessfulbuild".
1>ClCompile:
1>  All outputs are up-to-date.
1>  SFML_1.cpp
1>c:\documents and settings\teddybear\my documents\visual studio 2010\projects\sfml_1\sfml_1\sfml_1.cpp(1): warning C4627: '#include <SFML/System.hpp>': skipped when looking for precompiled header use
1>          Add directive to 'StdAfx.h' or rebuild precompiled header
1>c:\documents and settings\teddybear\my documents\visual studio 2010\projects\sfml_1\sfml_1\sfml_1.cpp(2): warning C4627: '#include <iostream>': skipped when looking for precompiled header use
1>          Add directive to 'StdAfx.h' or rebuild precompiled header
1>c:\documents and settings\teddybear\my documents\visual studio 2010\projects\sfml_1\sfml_1\sfml_1.cpp(19): fatal error C1010: unexpected end of file while looking for precompiled header. Did you forget to add '#include "StdAfx.h"' to your source?
1>
1>Build FAILED.
1>
1>Time Elapsed 00:00:00.29
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========


When I add

Code: [Select]
#include "stdafx." I get this build error:

Code: [Select]
1>------ Build started: Project: SFML_1, Configuration: Debug Win32 ------
1>Build started 9/14/2010 3:21:30 PM.
1>InitializeBuildStatus:
1>  Touching "Debug\SFML_1.unsuccessfulbuild".
1>ClCompile:
1>  All outputs are up-to-date.
1>  SFML_1.cpp
1>c:\documents and settings\teddybear\my documents\visual studio 2010\projects\sfml_1\sfml_1\sfml_1.cpp(1): warning C4627: '#include <SFML/System.hpp>': skipped when looking for precompiled header use
1>          Add directive to 'StdAfx.h' or rebuild precompiled header
1>c:\documents and settings\teddybear\my documents\visual studio 2010\projects\sfml_1\sfml_1\sfml_1.cpp(2): warning C4627: '#include <iostream>': skipped when looking for precompiled header use
1>          Add directive to 'StdAfx.h' or rebuild precompiled header
1>c:\documents and settings\teddybear\my documents\visual studio 2010\projects\sfml_1\sfml_1\sfml_1.cpp(7): error C2653: 'sf' : is not a class or namespace name
1>c:\documents and settings\teddybear\my documents\visual studio 2010\projects\sfml_1\sfml_1\sfml_1.cpp(7): error C2065: 'Clock' : undeclared identifier
1>c:\documents and settings\teddybear\my documents\visual studio 2010\projects\sfml_1\sfml_1\sfml_1.cpp(7): error C2146: syntax error : missing ';' before identifier 'Clock'
1>c:\documents and settings\teddybear\my documents\visual studio 2010\projects\sfml_1\sfml_1\sfml_1.cpp(7): error C2065: 'Clock' : undeclared identifier
1>c:\documents and settings\teddybear\my documents\visual studio 2010\projects\sfml_1\sfml_1\sfml_1.cpp(8): error C2065: 'Clock' : undeclared identifier
1>c:\documents and settings\teddybear\my documents\visual studio 2010\projects\sfml_1\sfml_1\sfml_1.cpp(8): error C2228: left of '.GetElapsedTime' must have class/struct/union
1>          type is ''unknown-type''
1>c:\documents and settings\teddybear\my documents\visual studio 2010\projects\sfml_1\sfml_1\sfml_1.cpp(8): fatal error C1903: unable to recover from previous error(s); stopping compilation
1>
1>Build FAILED.
1>
1>Time Elapsed 00:00:00.31
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========


I put the lib files exactly where the tutorial told me to, and the SFML folder exactly where it told me to as well. Help please? Thanks.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Can't compile example program with VC2010!
« Reply #1 on: September 14, 2010, 09:58:54 pm »
You should rather disable precompiled headers (unless you really need them, of course).
Laurent Gomila - SFML developer

Aerosol

  • Newbie
  • *
  • Posts: 5
    • View Profile
Can't compile example program with VC2010!
« Reply #2 on: September 14, 2010, 10:08:17 pm »
I set the properties of "stadfx.cpp" and "SFML-1.cpp" (this is my source file) to not use precompiled headers. I'm getting this build error:

Code: [Select]
1>------ Build started: Project: SFML_1, Configuration: Debug Win32 ------
1>Build started 9/14/2010 4:06:57 PM.
1>InitializeBuildStatus:
1>  Touching "Debug\SFML_1.unsuccessfulbuild".
1>ClCompile:
1>  SFML_1.cpp
1>c:\documents and settings\teddybear\my documents\visual studio 2010\projects\sfml_1\sfml_1\sfml_1.cpp(15): error C2059: syntax error : 'return'
1>c:\documents and settings\teddybear\my documents\visual studio 2010\projects\sfml_1\sfml_1\sfml_1.cpp(16): error C2059: syntax error : '}'
1>c:\documents and settings\teddybear\my documents\visual studio 2010\projects\sfml_1\sfml_1\sfml_1.cpp(16): error C2143: syntax error : missing ';' before '}'
1>c:\documents and settings\teddybear\my documents\visual studio 2010\projects\sfml_1\sfml_1\sfml_1.cpp(16): error C2059: syntax error : '}'
1>
1>Build FAILED.
1>
1>Time Elapsed 00:00:01.40
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Can't compile example program with VC2010!
« Reply #3 on: September 14, 2010, 10:29:27 pm »
Do you really think that we'll be able to help you without seeing the lines 15 and 16 of sfml_1.cpp? ;)
Laurent Gomila - SFML developer

panithadrum

  • Sr. Member
  • ****
  • Posts: 304
    • View Profile
    • Skyrpex@Github
    • Email
Can't compile example program with VC2010!
« Reply #4 on: September 14, 2010, 11:13:12 pm »
You add #include "stdafx." or #include "stdafx.H"?

Anyway, looks like you have some missing ";" or "}" in your code!

Aerosol

  • Newbie
  • *
  • Posts: 5
    • View Profile
Can't compile example program with VC2010!
« Reply #5 on: September 14, 2010, 11:23:11 pm »
Like I said, its the "compile your first SFML program" code. Here, I'll copy and paste it.

Code: [Select]
#include <SFML/System.hpp>
#include <iostream>

int main()
{
    sf::Clock Clock;
    while (Clock.GetElapsedTime() < 5.f)
    {
        std::cout << Clock.GetElapsedTime() << std::endl;
        sf::Sleep(0.5f);
    }

    return 0;
}

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Can't compile example program with VC2010!
« Reply #6 on: September 14, 2010, 11:54:03 pm »
Can we have the actual code that you compile? The one above doesn't even have 15 lines. I mean, maybe you made a mistake while copying / manipulating the original one.
Laurent Gomila - SFML developer

Aerosol

  • Newbie
  • *
  • Posts: 5
    • View Profile
Can't compile example program with VC2010!
« Reply #7 on: September 15, 2010, 12:35:54 am »
Code: [Select]
#include <SFML/System.hpp>
#include <iostream>

int main()
{
    sf::Clock Clock;
    while (Clock.GetElapsedTime() < 5.f)
    {
        std::cout << Clock.GetElapsedTime() << std::endl;
        sf::Sleep(0.5f);
    }

    return 0;
}
return 0;
}


Copied directly from my VC2010 window.

EDIT: I saw the error. Thanks for the precompiled header tip.

Nexus

  • SFML Team
  • Hero Member
  • *****
  • Posts: 6287
  • Thor Developer
    • View Profile
    • Bromeon
Can't compile example program with VC2010!
« Reply #8 on: September 15, 2010, 12:40:32 am »
Quote from: "Aerosol"
EDIT: I saw the error. Thanks for the precompiled header tip.
The problem is the
Code: [Select]
return 0;
}
outside of the main() function.
Zloxx II: action platformer
Thor Library: particle systems, animations, dot products, ...
SFML Game Development:

Aerosol

  • Newbie
  • *
  • Posts: 5
    • View Profile
Can't compile example program with VC2010!
« Reply #9 on: September 15, 2010, 12:55:39 am »
Yes I saw it. Thanks again.

Nexus

  • SFML Team
  • Hero Member
  • *****
  • Posts: 6287
  • Thor Developer
    • View Profile
    • Bromeon
Can't compile example program with VC2010!
« Reply #10 on: September 15, 2010, 01:49:08 am »
Oh sorry, I understood it like you found an error related to the precompiled header. But it's clear now. :)
Zloxx II: action platformer
Thor Library: particle systems, animations, dot products, ...
SFML Game Development: