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

Author Topic: On creation of new file showing no such file or directory  (Read 1800 times)

0 Members and 1 Guest are viewing this topic.

siddhant

  • Newbie
  • *
  • Posts: 2
    • View Profile
On creation of new file showing no such file or directory
« on: June 14, 2014, 10:42:27 am »
Whenever i create a new file or class in codeblocks and include <SFML/Graphics.hpp> or any sfml file it says no such file or directory.

when i work on single file it works fine just when i create a new file to include it in same project it start showing errors.

plz hepl me out i hv been trying to figure out the error for 2 days but couldnt correct it

Ixrec

  • Hero Member
  • *****
  • Posts: 1241
    • View Profile
    • Email
Re: On creation of new file showing no such file or directory
« Reply #1 on: June 14, 2014, 10:58:43 am »
Have you configured CodeBlocks per the official tutorial?  Part of that setup is telling it where to look for header files, so if it can't find the file you probably made a mistake around that step.

Quote
when i work on single file it works fine just when i create a new file to include it in same project it start showing errors.

Could you explain this more thoroughly?  I honestly have no idea what you're trying to say, partly because it's not clear what any of the "it"s are referring to.

siddhant

  • Newbie
  • *
  • Posts: 2
    • View Profile
Re: On creation of new file showing no such file or directory
« Reply #2 on: June 14, 2014, 12:43:31 pm »
Whenever I create a new file or class in code blocks and include Graphics header or any sfml header the compiler says no such file or directory.

When I work on a single file program works fine but when I create a new file and include the file in the same project then compiler starts showing errors.

It is showing this error:

E:\codes\sfml_project\main.cpp:1:29: fatal error: SFML/Graphics.hpp: No such file or directory

I even tried installing SFML 2.1 again and linking all the files to CodeBlocks but it is of no use.


I first created the project in codeblocks which contains main.cpp file and code

    #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;
   }
this works fine then i created a new class World and from file->new->class in codeblocks and included a file SFML/Graphics.hpp

the World class looks like

World.hpp file contains code

    #ifndef WORLD_HPP
    #define WORLD_HPP

    #include < SFML/Graphics.hpp >
    class World
    {
        public:
        World();
        protected:
        private:
    };

    #endif // WORLD_HPP
and World.cpp file contains

    #include "World.hpp"

    World::World()
    {
         //ctor
    }
at this point only the compiler starts showing error

E:\codes\sfml_project\World.hpp:4:29: fatal error: SFML/Graphics.hpp: No such file or directory

And all the files ( World.hpp , World.cpp , main.cpp ) are in the same folder.
« Last Edit: June 14, 2014, 12:52:56 pm by siddhant »

Ixrec

  • Hero Member
  • *****
  • Posts: 1241
    • View Profile
    • Email
Re: On creation of new file showing no such file or directory
« Reply #3 on: June 14, 2014, 12:58:05 pm »
It doesn't sound like you ever configured the project to include the SFML headers and libraries.  Read the official tutorial.  It covers that stuff.