SFML community forums
Help => Window => Topic started by: cdlink14 on July 30, 2011, 07:28:24 pm
-
I need help with using SFML in Code::Blocks, I have it all set up correctly, and I'm using the tutorial to try and draw a basic window but it's not showing
Here's the code:
#include <SFML/Window.hpp>
int main()
{
// Create the main window
sf::Window App(sf::VideoMode(800, 600, 32), "SFML Window");
// Start main loop
bool Running = true;
while (Running)
{
App.Display();
}
return EXIT_SUCCESS;
}
I know SFML is set up correctly as the code in this tutorial works perfectly:
http://www.sfml-dev.org/tutorials/1.6/start-cb.php
When I run the application I just get the console window:
http://dl.dropbox.com/u/3901038/FP/sfml/SFM2L.JPG
I've tried compiling in Debug and Release (using their respective dependencies).
Well when I set it to debug it doesn't seem to reach any breakpoints, it doesn't even reach "int main()", which leads me to believe this is an error with an header file...
Any help on how to go about finding/fixing it?
Also this happens running SFML on VS2008 (using the correct files/tutorials).
Specs:
windows 7 Pro x64
Code::Blocks 10.05
Visual Studio 2008
SFML C++ FULL SDK 1.6
Need anything else just ask.
-
ATI graphics card?
-
Yup ATI Radeon HD 5750 vapor-X 1GB if that helps.
-
SFML 1.6 (dynamic linking) doesn't work when combined with Windows and an ATI graphics card with recent drivers.
You can workaround the bug by linking statically to SFML, or switch to SFML 2.
-
Am I able to just install SFML 2 and it'll work straight off the bat with my current code? Or will I need to recode some things?
-
You need to change some code, see here (http://www.sfml-dev.org/forum/viewtopic.php?t=5343).
-
Also I can't seem to find the lib folder in the archive.
-
There's no release yet, the archive contains the current development code, you must compile it yourself.
-
Ok so I'm trying to compile them using Cmake, but when I try to compile for "CodeBlocks - MinGW Makefiles" or just "MinGW Makefiles" I get an error
CMake Error: CMake was unable to find a build program corresponding to "MinGW Makefiles". CMAKE_MAKE_PROGRAM is not set. You probably need to select a different build tool.
-
Is MinGW installed on your computer? Maybe there needs to be a PATH (environment variable) entry for the directory containing g++.exe.
-
MinGW came installed with my code::blocks, where would I find the path variable to edit?
-
(http://dl.dropbox.com/u/3901038/helpme.JPG)
Which one is the Cmake compiler I'm supposed to use?
-
CMake is not a compiler ;) it's a very powerful compiler's "project" generation tools that you need to install from http://www.cmake.org/ .
edit : ahm, didn't read the entire post.
Open the cmake-gui, set it to SFML's directory, clear the cache (in file menu), then configure.
a window appear and you have 4 choices, choose native compiler, but with the option to define the compilers yourself, and then choose g++.exe for C++; gcc.exe for C ;) .
-
where would I find the path variable to edit?
Control panel -> System -> Advanced system settings -> Advanced -> Environment variables. Check if the PATH entry contains the bin folder of MinGW.
There are also direct ways, one of which is the shell command SET. Or use the start search ;)
-
CMake is not a compiler ;) it's a very powerful compiler's "project" generation tools that you need to install from http://www.cmake.org/ .
edit : ahm, didn't read the entire post.
Open the cmake-gui, set it to SFML's directory, clear the cache (in file menu), then configure.
a window appear and you have 4 choices, choose native compiler, but with the option to define the compilers yourself, and then choose g++.exe for C++; gcc.exe for C ;) .
When I try that I get this:
CMake Error: CMake was unable to find a build program corresponding to "MinGW Makefiles". CMAKE_MAKE_PROGRAM is not set. You probably need to select a different build tool.
CMake Error: CMake was unable to find a build program corresponding to "MinGW Makefiles". CMAKE_MAKE_PROGRAM is not set. You probably need to select a different build tool.
CMake Error: Error required internal CMake variable not set, cmake may be not be built correctly.
Missing variable is:
CMAKE_C_COMPILER_ENV_VAR
CMake Error: Error required internal CMake variable not set, cmake may be not be built correctly.
Missing variable is:
CMAKE_C_COMPILER
CMake Error: Could not find cmake module file:D:/Users/user/Desktop/LaurentGomila-SFML-732b789-BUILD/CMakeFiles/CMakeCCompiler.cmake
CMake Error: Error required internal CMake variable not set, cmake may be not be built correctly.
Missing variable is:
CMAKE_CXX_COMPILER_ENV_VAR
CMake Error: Could not find cmake module file:D:/Users/user/Desktop/LaurentGomila-SFML-732b789-BUILD/CMakeFiles/CMakeCXXCompiler.cmake
CMake Error: CMAKE_C_COMPILER not set, after EnableLanguage
Configuring incomplete, errors occurred!
-
Well now I'm getting really Pi**ed off.
I've tried doing as danman said and I still get the same error about not being able to find the "build program".
I've even tried setting the PATH environment variable to the MinGW folder, and still the same error message!
Is there any particular reason why the libraries can't just be pre-compiled and included? Because this is giving me a serious headache. And I'm just considering giving up all together.
-
Ok so I downloaded MinGW from the MinGW website and installed that (I don't see why I should need too, but meh it's not like it wastes disk space on my already filled hard disk).
I've managed to run Cmake
I get this output:
The C compiler identification is GNU
The CXX compiler identification is GNU
Check for working C compiler: D:/Program Files (x86)/CodeBlocks/MinGW/bin/gcc.exe
Check for working C compiler: D:/Program Files (x86)/CodeBlocks/MinGW/bin/gcc.exe -- works
Detecting C compiler ABI info
Detecting C compiler ABI info - done
Check for working CXX compiler: D:/Program Files (x86)/CodeBlocks/MinGW/bin/g++.exe
Check for working CXX compiler: D:/Program Files (x86)/CodeBlocks/MinGW/bin/g++.exe -- works
Detecting CXX compiler ABI info
Detecting CXX compiler ABI info - done
Looking for sys/types.h
Looking for sys/types.h - found
Looking for stdint.h
Looking for stdint.h - found
Looking for stddef.h
Looking for stddef.h - found
Check size of void*
Check size of void* - done
Found OpenGL: opengl32
Found Freetype: D:/Users/user/Desktop/LaurentGomila-SFML-732b789/extlibs/libs-mingw/libfreetype.a
Found GLEW: D:/Users/user/Desktop/LaurentGomila-SFML-732b789/extlibs/libs-mingw/libglew.a
Found JPEG: D:/Users/user/Desktop/LaurentGomila-SFML-732b789/extlibs/libs-mingw/libjpeg.a
Found OpenAL: D:/Users/user/Desktop/LaurentGomila-SFML-732b789/extlibs/libs-mingw/libopenal32.a
Found SNDFILE: D:/Users/user/Desktop/LaurentGomila-SFML-732b789/extlibs/libs-mingw/libsndfile.a
Configuring done
Generating done
But no matter where I look there is no Library files?
I know it's still in very development but seriously does the SFML 2.0 tutorial have to be so complex? I sped through the 1.6 tutorial without a single problem but this 2.0 tutorial is seriously starting to grind my gears.
-
I know it's still in very development but seriously does the SFML 2.0 tutorial have to be so complex? I sped through the 1.6 tutorial without a single problem but this 2.0 tutorial is seriously starting to grind my gears.
SFML 2 will be precompiled when it's publicly released. Until it happens, you use a development snapshot so you have to compile it yourself.
It may seem difficult the first time you use CMake, but it's only basic stuff, really. Putting a path in the PATH environment variable is useful for many other situations, learning how to do this is a good thing for a programer -- especially when dealing with several compiler versions, or several versions of the same library.
Don't say "SFML 2 is hard to compile", but rather "nice, I've learnt very important Windows stuff today" ;)
But no matter where I look there is no Library files?
You've only generated the project/makefiles that can compile SFML. Now you need to compile it (mingw32-make).
This is explained in the tutorial.
-
Ok I apologize if I seemed to get a bit angry, I have been having a bad time lately (I broke my ankle so I am stuck in my room until it gets better) so things are annoying me a lot recently.
I do have some other problems I want to post, but I'll post them later, for now I want to take a break and play some GTA IV. :wink:
-
if (App.GetInput().IsKeyDown(sf::Key::RBracket)) Sprite.Scale(1.001f, 1.001f);
if (App.GetInput().IsKeyDown(sf::Key::LBracket)) Sprite.Scale(1.001f, 1.001f);
My problem is on the second line, I have no idea how I do a float backwards (so the image downscales, instead of upscaling).
Can someone provide me info on how to do this I want to learn about this before moving to the next part of the tutorial?
-
My problem is on the second line, I have no idea how I do a float backwards (so the image downscales, instead of upscaling).
0.999 ;)
-
Ok thanks, an additional question.
How would I go about converting App.GetFrameTime into a string so I can alter it and output it as text on the screen to show the FPS?
-
How would I go about converting App.GetFrameTime into a string
That's a regular C++ "int to string" conversion, you'll find thousands of relevant answers on Google ;)
-
You can have a look at this thread. http://www.sfml-dev.org/forum/viewtopic.php?p=33757
EDIT : not fast enough =P