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

Author Topic: Trying to get SFML running in CodeBlocks with MinGW, doesn't like some hpp files  (Read 4403 times)

0 Members and 1 Guest are viewing this topic.

GC13

  • Newbie
  • *
  • Posts: 7
    • View Profile
    • Email
I'm trying to get SFML going on Windows 8 in CodeBlocks. I thought I had everything going nicely, but the test code is spitting fire at me when I try to build. It's certainly an improvement from it complaining about the namespace when I didn't specify a file extension so it defaulted to .c, but now it's complaining about Time.hpp and Export.hpp from System.

It's detected MinGW nicely, and the "GNU GCC Compiler" is my selected and default compiler and has the right path.

Any clue what's going wrong?

mingw32-g++.exe   -IC:\SFML-2.1\include  -c "D:\Chris\My Documents\SFML Test\main.cpp" -o "D:\Chris\My Documents\SFML Test\main.o"
In file included from C:\SFML-2.1\include/SFML/System.hpp:32:0,
                 from C:\SFML-2.1\include/SFML/Window.hpp:32,
                 from C:\SFML-2.1\include/SFML/Graphics.hpp:32,
                 from D:\Chris\My Documents\SFML Test\main.cpp:1:
C:\SFML-2.1\include/SFML/Config.hpp:1:1: error: 'include' does not name a type
 include <SFML/Graphics.hpp>
 ^
In file included from C:\SFML-2.1\include/SFML/System/Export.hpp:31:0,
                 from C:\SFML-2.1\include/SFML/System/Clock.hpp:31,
                 from C:\SFML-2.1\include/SFML/System.hpp:33,
                 from C:\SFML-2.1\include/SFML/Window.hpp:32,
                 from C:\SFML-2.1\include/SFML/Graphics.hpp:32,
                 from D:\Chris\My Documents\SFML Test\main.cpp:1:
C:\SFML-2.1\include/SFML/Config.hpp:1:1: error: 'include' does not name a type
 include <SFML/Graphics.hpp>
 ^
In file included from C:\SFML-2.1\include/SFML/System/Clock.hpp:32:0,
                 from C:\SFML-2.1\include/SFML/System.hpp:33,
                 from C:\SFML-2.1\include/SFML/Window.hpp:32,
                 from C:\SFML-2.1\include/SFML/Graphics.hpp:32,
                 from D:\Chris\My Documents\SFML Test\main.cpp:1:
C:\SFML-2.1\include/SFML/System/Time.hpp:40:23: error: variable 'sf::SFML_API_IMPORT sf::Time' has initializer but incomplete type
 class SFML_SYSTEM_API Time
                       ^
C:\SFML-2.1\include/SFML/System/Time.hpp:40:23: warning: extended initializer lists only available with -std=c++11 or -std=gnu++11 [enabled by default]
C:\SFML-2.1\include/SFML/System/Time.hpp:42:1: error: expected primary-expression before 'public'
 public :
 ^
C:\SFML-2.1\include/SFML/System/Time.hpp:42:1: error: expected '}' before 'public'
C:\SFML-2.1\include/SFML/System/Time.hpp:42:1: error: expected ',' or ';' before 'public'
C:\SFML-2.1\include/SFML/System/Time.hpp:60:23: error: non-member function 'float sf::asSeconds()' cannot have cv-qualifier
     float asSeconds() const;
                       ^
C:\SFML-2.1\include/SFML/System/Time.hpp:70:5: error: 'Int32' does not name a type
     Int32 asMilliseconds() const;
     ^
C:\SFML-2.1\include/SFML/System/Time.hpp:80:5: error: 'Int64' does not name a type
     Int64 asMicroseconds() const;
     ^
C:\SFML-2.1\include/SFML/System/Time.hpp:85:18: error: 'Time' does not name a type
     static const Time Zero; ///< Predefined "zero" time value
                  ^
C:\SFML-2.1\include/SFML/System/Time.hpp:87:1: error: expected unqualified-id before 'private'
 private :
 ^
C:\SFML-2.1\include/SFML/System/Time.hpp:90:5: error: 'friend' used outside of class
     friend SFML_SYSTEM_API Time milliseconds(Int32);
     ^
C:\SFML-2.1\include/SFML/System/Time.hpp:90:33: error: expected initializer before 'milliseconds'
     friend SFML_SYSTEM_API Time milliseconds(Int32);
                                 ^
C:\SFML-2.1\include/SFML/System/Time.hpp:91:5: error: 'friend' used outside of class
     friend SFML_SYSTEM_API Time microseconds(Int64);
     ^
C:\SFML-2.1\include/SFML/System/Time.hpp:91:33: error: expected initializer before 'microseconds'
     friend SFML_SYSTEM_API Time microseconds(Int64);
                                 ^
C:\SFML-2.1\include/SFML/System/Time.hpp:102:19: error: ISO C++ forbids declaration of 'Time' with no type [-fpermissive]
     explicit Time(Int64 microseconds);
                   ^
C:\SFML-2.1\include/SFML/System/Time.hpp:102:19: error: only declarations of constructors can be 'explicit'
C:\SFML-2.1\include/SFML/System/Time.hpp:102:19: error: 'Int64' was not declared in this scope
C:\SFML-2.1\include/SFML/System/Time.hpp:104:1: error: expected unqualified-id before 'private'
 private :
 ^
In file included from C:\SFML-2.1\include/SFML/System/Clock.hpp:31:0,
                 from C:\SFML-2.1\include/SFML/System.hpp:33,
                 from C:\SFML-2.1\include/SFML/Window.hpp:32,
                 from C:\SFML-2.1\include/SFML/Graphics.hpp:32,
                 from D:\Chris\My Documents\SFML Test\main.cpp:1:
C:\SFML-2.1\include/SFML/System/Export.hpp:43:29: error: 'SFML_API_IMPORT' does not name a type
     #define SFML_SYSTEM_API SFML_API_IMPORT
                             ^
C:\SFML-2.1\include/SFML/System/Time.hpp:123:1: note: in expansion of macro 'SFML_SYSTEM_API'
 SFML_SYSTEM_API Time seconds(float amount);
 ^
C:\SFML-2.1\include/SFML/System/Export.hpp:43:29: error: 'SFML_API_IMPORT' does not name a type
     #define SFML_SYSTEM_API SFML_API_IMPORT
                             ^
C:\SFML-2.1\include/SFML/System/Time.hpp:136:1: note: in expansion of macro 'SFML_SYSTEM_API'
 SFML_SYSTEM_API Time milliseconds(Int32 amount);
 ^
C:\SFML-2.1\include/SFML/System/Export.hpp:43:29: error: 'SFML_API_IMPORT' does not name a type
     #define SFML_SYSTEM_API SFML_API_IMPORT
                             ^
C:\SFML-2.1\include/SFML/System/Time.hpp:149:1: note: in expansion of macro 'SFML_SYSTEM_API'
 SFML_SYSTEM_API Time microseconds(Int64 amount);
 ^
C:\SFML-2.1\include/SFML/System/Export.hpp:43:29: error: 'SFML_API_IMPORT' does not name a type
     #define SFML_SYSTEM_API SFML_API_IMPORT
                             ^
C:\SFML-2.1\include/SFML/System/Time.hpp:161:1: note: in expansion of macro 'SFML_SYSTEM_API'
 SFML_SYSTEM_API bool operator ==(Time left, Time right);
 ^
C:\SFML-2.1\include/SFML/System/Export.hpp:43:29: error: 'SFML_API_IMPORT' does not name a type
     #define SFML_SYSTEM_API SFML_API_IMPORT
                             ^
C:\SFML-2.1\include/SFML/System/Time.hpp:173:1: note: in expansion of macro 'SFML_SYSTEM_API'
 SFML_SYSTEM_API bool operator !=(Time left, Time right);
 ^
C:\SFML-2.1\include/SFML/System/Export.hpp:43:29: error: 'SFML_API_IMPORT' does not name a type
     #define SFML_SYSTEM_API SFML_API_IMPORT
                             ^
C:\SFML-2.1\include/SFML/System/Time.hpp:185:1: note: in expansion of macro 'SFML_SYSTEM_API'
 SFML_SYSTEM_API bool operator <(Time left, Time right);
 ^
C:\SFML-2.1\include/SFML/System/Export.hpp:43:29: error: 'SFML_API_IMPORT' does not name a type
     #define SFML_SYSTEM_API SFML_API_IMPORT
                             ^
C:\SFML-2.1\include/SFML/System/Time.hpp:197:1: note: in expansion of macro 'SFML_SYSTEM_API'
 SFML_SYSTEM_API bool operator >(Time left, Time right);
 ^
C:\SFML-2.1\include/SFML/System/Export.hpp:43:29: error: 'SFML_API_IMPORT' does not name a type
     #define SFML_SYSTEM_API SFML_API_IMPORT
                             ^
C:\SFML-2.1\include/SFML/System/Time.hpp:209:1: note: in expansion of macro 'SFML_SYSTEM_API'
 SFML_SYSTEM_API bool operator <=(Time left, Time right);
 ^
C:\SFML-2.1\include/SFML/System/Export.hpp:43:29: error: 'SFML_API_IMPORT' does not name a type
     #define SFML_SYSTEM_API SFML_API_IMPORT
                             ^
C:\SFML-2.1\include/SFML/System/Time.hpp:221:1: note: in expansion of macro 'SFML_SYSTEM_API'
 SFML_SYSTEM_API bool operator >=(Time left, Time right);
 ^
C:\SFML-2.1\include/SFML/System/Export.hpp:43:29: error: 'SFML_API_IMPORT' does not name a type
     #define SFML_SYSTEM_API SFML_API_IMPORT
                             ^
C:\SFML-2.1\include/SFML/System/Time.hpp:232:1: note: in expansion of macro 'SFML_SYSTEM_API'
 SFML_SYSTEM_API Time operator -(Time right);
 ^
C:\SFML-2.1\include/SFML/System/Export.hpp:43:29: error: 'SFML_API_IMPORT' does not name a type
     #define SFML_SYSTEM_API SFML_API_IMPORT
                             ^
C:\SFML-2.1\include/SFML/System/Time.hpp:244:1: note: in expansion of macro 'SFML_SYSTEM_API'
 SFML_SYSTEM_API Time operator +(Time left, Time right);
 ^
C:\SFML-2.1\include/SFML/System/Export.hpp:43:29: error: 'SFML_API_IMPORT' does not name a type
     #define SFML_SYSTEM_API SFML_API_IMPORT
                             ^
C:\SFML-2.1\include/SFML/System/Time.hpp:256:1: note: in expansion of macro 'SFML_SYSTEM_API'
 SFML_SYSTEM_API Time& operator +=(Time& left, Time right);
 ^
C:\SFML-2.1\include/SFML/System/Export.hpp:43:29: error: 'SFML_API_IMPORT' does not name a type
     #define SFML_SYSTEM_API SFML_API_IMPORT
                             ^
C:\SFML-2.1\include/SFML/System/Time.hpp:268:1: note: in expansion of macro 'SFML_SYSTEM_API'
 SFML_SYSTEM_API Time operator -(Time left, Time right);
 ^
C:\SFML-2.1\include/SFML/System/Export.hpp:43:29: error: 'SFML_API_IMPORT' does not name a type
     #define SFML_SYSTEM_API SFML_API_IMPORT
                             ^
C:\SFML-2.1\include/SFML/System/Time.hpp:280:1: note: in expansion of macro 'SFML_SYSTEM_API'
 SFML_SYSTEM_API Time& operator -=(Time& left, Time right);
 ^
C:\SFML-2.1\include/SFML/System/Export.hpp:43:29: error: 'SFML_API_IMPORT' does not name a type
     #define SFML_SYSTEM_API SFML_API_IMPORT
                             ^
C:\SFML-2.1\include/SFML/System/Time.hpp:292:1: note: in expansion of macro 'SFML_SYSTEM_API'
 SFML_SYSTEM_API Time operator *(Time left, float right);
 ^
C:\SFML-2.1\include/SFML/System/Export.hpp:43:29: error: 'SFML_API_IMPORT' does not name a type
     #define SFML_SYSTEM_API SFML_API_IMPORT
                             ^
C:\SFML-2.1\include/SFML/System/Time.hpp:304:1: note: in expansion of macro 'SFML_SYSTEM_API'
 SFML_SYSTEM_API Time operator *(Time left, Int64 right);
 ^
C:\SFML-2.1\include/SFML/System/Export.hpp:43:29: error: 'SFML_API_IMPORT' does not name a type
     #define SFML_SYSTEM_API SFML_API_IMPORT
                             ^
C:\SFML-2.1\include/SFML/System/Time.hpp:316:1: note: in expansion of macro 'SFML_SYSTEM_API'
 SFML_SYSTEM_API Time operator *(float left, Time right);
 ^
C:\SFML-2.1\include/SFML/System/Export.hpp:43:29: error: 'SFML_API_IMPORT' does not name a type
     #define SFML_SYSTEM_API SFML_API_IMPORT
                             ^
C:\SFML-2.1\include/SFML/System/Time.hpp:328:1: note: in expansion of macro 'SFML_SYSTEM_API'
 SFML_SYSTEM_API Time operator *(Int64 left, Time right);
 ^
C:\SFML-2.1\include/SFML/System/Export.hpp:43:29: error: 'SFML_API_IMPORT' does not name a type
     #define SFML_SYSTEM_API SFML_API_IMPORT
                             ^
C:\SFML-2.1\include/SFML/System/Time.hpp:340:1: note: in expansion of macro 'SFML_SYSTEM_API'
 SFML_SYSTEM_API Time& operator *=(Time& left, float right);
 ^
C:\SFML-2.1\include/SFML/System/Export.hpp:43:29: error: 'SFML_API_IMPORT' does not name a type
     #define SFML_SYSTEM_API SFML_API_IMPORT
                             ^
C:\SFML-2.1\include/SFML/System/Time.hpp:352:1: note: in expansion of macro 'SFML_SYSTEM_API'
 SFML_SYSTEM_API Time& operator *=(Time& left, Int64 right);
 ^
C:\SFML-2.1\include/SFML/System/Export.hpp:43:29: error: 'SFML_API_IMPORT' does not name a type
     #define SFML_SYSTEM_API SFML_API_IMPORT
                             ^
C:\SFML-2.1\include/SFML/System/Time.hpp:364:1: note: in expansion of macro 'SFML_SYSTEM_API'
 SFML_SYSTEM_API Time operator /(Time left, float right);
 ^
C:\SFML-2.1\include/SFML/System/Export.hpp:43:29: error: 'SFML_API_IMPORT' does not name a type
     #define SFML_SYSTEM_API SFML_API_IMPORT
                             ^
C:\SFML-2.1\include/SFML/System/Time.hpp:376:1: note: in expansion of macro 'SFML_SYSTEM_API'
 SFML_SYSTEM_API Time operator /(Time left, Int64 right);
 ^
C:\SFML-2.1\include/SFML/System/Export.hpp:43:29: error: 'SFML_API_IMPORT' does not name a type
     #define SFML_SYSTEM_API SFML_API_IMPORT
                             ^
C:\SFML-2.1\include/SFML/System/Time.hpp:388:1: note: in expansion of macro 'SFML_SYSTEM_API'
 SFML_SYSTEM_API Time& operator /=(Time& left, float right);
 ^
C:\SFML-2.1\include/SFML/System/Export.hpp:43:29: error: 'SFML_API_IMPORT' does not name a type
     #define SFML_SYSTEM_API SFML_API_IMPORT
                             ^
C:\SFML-2.1\include/SFML/System/Time.hpp:400:1: note: in expansion of macro 'SFML_SYSTEM_API'
 SFML_SYSTEM_API Time& operator /=(Time& left, Int64 right);
 ^
In file included from C:\SFML-2.1\include/SFML/System/Clock.hpp:32:0,
                 from C:\SFML-2.1\include/SFML/System.hpp:33,
                 from C:\SFML-2.1\include/SFML/Window.hpp:32,
                 from C:\SFML-2.1\include/SFML/Graphics.hpp:32,
                 from D:\Chris\My Documents\SFML Test\main.cpp:1:
C:\SFML-2.1\include/SFML/System/Time.hpp:402:1: error: expected declaration before '}' token
 } // namespace sf
 ^
Process terminated with status 1 (0 minutes, 1 seconds)
44 errors, 1 warnings (0 minutes, 1 seconds)

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11032
    • View Profile
    • development blog
    • Email
Not sure what you did, but it seems like you've corrupted some SFML headers.

In file included from C:\SFML-2.1\include/SFML/System.hpp:32:0,
                 from C:\SFML-2.1\include/SFML/Window.hpp:32,
                 from C:\SFML-2.1\include/SFML/Graphics.hpp:32,
                 from D:\Chris\My Documents\SFML Test\main.cpp:1:
C:\SFML-2.1\include/SFML/Config.hpp:1:1: error: 'include' does not name a type
 include <SFML/Graphics.hpp>
 ^
In file included from C:\SFML-2.1\include/SFML/System/Export.hpp:31:0,
                 from C:\SFML-2.1\include/SFML/System/Clock.hpp:31,
                 from C:\SFML-2.1\include/SFML/System.hpp:33,
                 from C:\SFML-2.1\include/SFML/Window.hpp:32,
                 from C:\SFML-2.1\include/SFML/Graphics.hpp:32,
                 from D:\Chris\My Documents\SFML Test\main.cpp:1:
C:\SFML-2.1\include/SFML/Config.hpp:1:1: error: 'include' does not name a type
 include <SFML/Graphics.hpp>
 ^
This means, that instead of having #include the '#' is missing, which should not happen, unless one manually edits the Config.hpp file.

C:\SFML-2.1\include/SFML/System/Time.hpp:40:23: warning: extended initializer lists only available with -std=c++11 or -std=gnu++11 [enabled by default]
SFML doesn't use C++11 yet, thus this indicates that the compiler is trying to interpret something in a wrong way.

C:\SFML-2.1\include/SFML/System/Time.hpp:42:1: error: expected primary-expression before 'public'
 public :
 ^
C:\SFML-2.1\include/SFML/System/Time.hpp:42:1: error: expected '}' before 'public'
C:\SFML-2.1\include/SFML/System/Time.hpp:42:1: error: expected ',' or ';' before 'public'

 ^
In file included from C:\SFML-2.1\include/SFML/System/Clock.hpp:32:0,
                 from C:\SFML-2.1\include/SFML/System.hpp:33,
                 from C:\SFML-2.1\include/SFML/Window.hpp:32,
                 from C:\SFML-2.1\include/SFML/Graphics.hpp:32,
                 from D:\Chris\My Documents\SFML Test\main.cpp:1:
C:\SFML-2.1\include/SFML/System/Time.hpp:402:1: error: expected declaration before '}' token
 } // namespace sf
 ^
This all may or may not be due to the corruption from above.

So what exactly did you do with the SFML headers? You should try to grab the clean ones form the download page.
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

GC13

  • Newbie
  • *
  • Posts: 7
    • View Profile
    • Email
I haven't touched them. I copied the SFML directory out of the zip file and placed it directly into the C drive. It ran its extraction properly as far as I can tell (I'd imagine it would complain about more than just those two files if it didn't try to extract it).

The video tutorial I went to after the text tutorial didn't work has me using these linker options, but the errors are the same without them:
-static-libgcc
-static-libstdc++
-std=c++11

In Linker Settings I'm linking to the -s libraries in the Release section, and the -s-d libraries in the Debug section.

If I have some corrupted headers, does that mean that simply re-downloading the GCC 4.7 MinGW (DW2) - 32 bits version of SFML and placing it in the same filepath should fix the problem?

binary1248

  • SFML Team
  • Hero Member
  • *****
  • Posts: 1405
  • I am awesome.
    • View Profile
    • The server that really shouldn't be running
So... what does your main.cpp look like? Post it here in it's entirety (in code tags of course).
SFGUI # SFNUL # GLS # Wyrm <- Why do I waste my time on such a useless project? Because I am awesome (first meaning).

GC13

  • Newbie
  • *
  • Posts: 7
    • View Profile
    • Email
I copied it straight from the tutorial. Here's what made its way into my project:
#include <SFML/Graphics.hpp>

int main()
{
    sf::RenderWindow window(sf::VideoMode(200, 200), "SFML works!");
    sf::CircleShape shape(100.f);
    shape.setFillColor(sf::Color::Green);

    while (window.isOpen())
    {
        sf::Event event;
        while (window.pollEvent(event))
        {
            if (event.type == sf::Event::Closed)
                window.close();
        }

        window.clear();
        window.draw(shape);
        window.display();
    }

    return 0;
}
 

binary1248

  • SFML Team
  • Hero Member
  • *****
  • Posts: 1405
  • I am awesome.
    • View Profile
    • The server that really shouldn't be running
Does this compile?
#include <SFML/Config.hpp>
int main() {}
SFGUI # SFNUL # GLS # Wyrm <- Why do I waste my time on such a useless project? Because I am awesome (first meaning).

GC13

  • Newbie
  • *
  • Posts: 7
    • View Profile
    • Email
No, I get the error "C:\SFML-2.1\include\SFML\Config.hpp|1|error: 'include' does not name a type|". Then it pulls up a config.hpp that looks like this:
include <SFML/Graphics.hpp>

int main()
{
    sf::RenderWindow window(sf::VideoMode(200, 200), "SFML works!");
    sf::CircleShape shape(100.f);
    shape.setFillColor(sf::Color::Green);

    while (window.isOpen())
    {
        sf::Event event;
        while (window.pollEvent(event))
        {
            if (event.type == sf::Event::Closed)
                window.close();
        }

        window.clear();
        window.draw(shape);
        window.display();
    }

    return 0;
}
 

binary1248

  • SFML Team
  • Hero Member
  • *****
  • Posts: 1405
  • I am awesome.
    • View Profile
    • The server that really shouldn't be running
What about this? Does this compile if you paste it in the same project?
#include <iostream>
int main() {}
SFGUI # SFNUL # GLS # Wyrm <- Why do I waste my time on such a useless project? Because I am awesome (first meaning).

GC13

  • Newbie
  • *
  • Posts: 7
    • View Profile
    • Email
What about this? Does this compile if you paste it in the same project?
#include <iostream>
int main() {}
Yeah, that one runs just fine. Lets me add in a "Hello world" and everything.

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11032
    • View Profile
    • development blog
    • Email
What's the content of the Config.hpp?
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

GC13

  • Newbie
  • *
  • Posts: 7
    • View Profile
    • Email
What's the content of the Config.hpp?
The one I can access matches the one it spits out at me when it's complaining about it:
int main()
{
    sf::RenderWindow window(sf::VideoMode(200, 200), "SFML works!");
    sf::CircleShape shape(100.f);
    shape.setFillColor(sf::Color::Green);

    while (window.isOpen())
    {
        sf::Event event;
        while (window.pollEvent(event))
        {
            if (event.type == sf::Event::Closed)
                window.close();
        }

        window.clear();
        window.draw(shape);
        window.display();
    }

    return 0;
}
 

wintertime

  • Sr. Member
  • ****
  • Posts: 255
    • View Profile
Either you put a main function into a header file (which is seriously wrong thing to do) or you posted the wrong file (get the one listed in the error message).

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11032
    • View Profile
    • development blog
    • Email
So you're saying "C:\SFML-2.1\include\SFML\Config.hpp" contains the example code? :o
Well then you've edited that file after all without noticing it. ;)
« Last Edit: December 19, 2013, 12:34:18 am by eXpl0it3r »
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

GC13

  • Newbie
  • *
  • Posts: 7
    • View Profile
    • Email
I have a pretty good idea how that happened (I was a touch confused by the new compiler's habit of opening up files it was mad with), but I've restored Config.hpp from the version held in the .zip. Everything's set up properly now, so that was the last fix I needed.

Thank you for your patience. I hope to have more complicated questions for you in the future.  8)