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

Author Topic: (HELP!) I am having problems setting up SFML with Codeblock  (Read 11662 times)

0 Members and 1 Guest are viewing this topic.

T-Trojan

  • Newbie
  • *
  • Posts: 9
    • View Profile
(HELP!) I am having problems setting up SFML with Codeblock
« on: April 08, 2010, 08:32:00 pm »
Hi, I downloaded the latest SFML 1.6 and followed the tutorial very carefully, I also downloaded the latest Codeblocks with the compiler included into that.

I am doing everything on the memory stick.

1) I copied SFML foulder from F:\SFML-1.6\include to F:\CodeBlocks\MinGW\include

2) It said to copy all the .a files from F:\SFML-1.6\lib\mingw but in mingw there were no files, but I saw .a files in F:\SFML-1.6\lib\ instead and copied them into F:\CodeBlocks\MinGW\lib where I saw many other .a files

3) I went into Compiler and Debugger and set the directory for search directory for compiler to Step 1)

4) I set the linker search directory to Step 2

5) I went into build options and in Linker settings --> Other linker

added this

-lsfml-graphics
-lsfml-window
-lsfml-system

6) I added SFML_DYNAMIC in compiler settings --> #define

I used this code in the new project


#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;
}



and it opens the black executable window with an error when I compile and execute.

It says.
The application has failed to start because sfml-system.dll was not found.
Reinstalling the application ...etc.

In the codeblocks build log it says

Checking for existence: F:\Programming\presentation\OpenGL\bin\Debug\OpenGL.exe
Executing: "F:\CodeBlocks/cb_console_runner.exe" "F:\Programming\presentation\OpenGL\bin\Debug\OpenGL.exe"  (in F:\Programming\presentation\OpenGL\.)
Process terminated with status -1073741515 (0 minutes, 40 seconds)
 



I need this to get working to do a school project, so any help would be greatly appreciated.

Thanks in advance.

nulloid

  • Full Member
  • ***
  • Posts: 134
    • View Profile
(HELP!) I am having problems setting up SFML with Codeblock
« Reply #1 on: April 08, 2010, 09:24:48 pm »
Well, I think you need to decide whther you are using static, or dynamic libraries. Because you defined SFML_DYNAMIC, which is only needed when you are using dynamic libraries (.dll), but you just set the static libraries (.a). IMHO. :)

Mindiell

  • Hero Member
  • *****
  • Posts: 1261
    • ICQ Messenger - 41484135
    • View Profile
(HELP!) I am having problems setting up SFML with Codeblock
« Reply #2 on: April 08, 2010, 09:26:32 pm »
It seems you have not copied dll files.

By the way :
Quote from: "the 1.6 tuto"
Copy the *.a files in SFML-x.y\lib to the \lib directory of your Code::Blocks installation


If you read all the tuto and not just the beginning (I'm ok this could be clearer) :
Quote from: "the 1.6 tuto"
Your program should now compile, link and run fine. If you linked against the dynamic versions of the SFML libraries, donc forget to copy the corresponding DLLs (sfml-system.dll in this case) to your executable's directory, or to a directory contained in the PATH environment variable.


 :wink:
Mindiell
----

T-Trojan

  • Newbie
  • *
  • Posts: 9
    • View Profile
(HELP!) I am having problems setting up SFML with Codeblock
« Reply #3 on: April 08, 2010, 09:34:05 pm »
Quote from: "nulloid"
Well, I think you need to decide whther you are using static, or dynamic libraries. Because you defined SFML_DYNAMIC, which is only needed when you are using dynamic libraries (.dll), but you just set the static libraries (.a). IMHO. :)


Hey thanks for the reply.

Well When I copied the .a files I copied the .dll files with it just incase, so the dll files are there, but it still gives me an error.

So then I tried removing the SFML_DYNAMIC but it stll gives the same error.


:(

EDIT: Now I added all of these files (.a and dlls) into the project directory too, (executable directory I guess? )

Now it says The appluicatio nhas failed to start because libgcc_s_dw2-1.dll was not found

And out of all dlls this one is not sfml, I cannot find it.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
(HELP!) I am having problems setting up SFML with Codeblock
« Reply #4 on: April 08, 2010, 09:53:47 pm »
Quote
Well When I copied the .a files I copied the .dll files with it just incase, so the dll files are there, but it still gives me an error.

The lib path is known by the linker, not by the OS (and it's the OS that tries to find the DLLs when you launch your application).

Quote
Now it says The appluicatio nhas failed to start because libgcc_s_dw2-1.dll was not found

This is a gcc DLL. It is located in <your_installation_of_mingw>/bin. Or you can add -static-libgcc to the linker options to get rid of it.
Laurent Gomila - SFML developer

T-Trojan

  • Newbie
  • *
  • Posts: 9
    • View Profile
(HELP!) I am having problems setting up SFML with Codeblock
« Reply #5 on: April 08, 2010, 10:06:33 pm »
Quote from: "Laurent"
Quote
Well When I copied the .a files I copied the .dll files with it just incase, so the dll files are there, but it still gives me an error.

The lib path is known by the linker, not by the OS (and it's the OS that tries to find the DLLs when you launch your application).

Quote
Now it says The appluicatio nhas failed to start because libgcc_s_dw2-1.dll was not found

This is a gcc DLL. It is located in <your_installation_of_mingw>/bin. Or you can add -static-libgcc to the linker options to get rid of it.


Hi, thanks for dropping by.

For your first point, what does that even mean? OS? Do I need to fix it? Because I really don't know what dynamic library is, I was just trying to get my program to at least compiler and run.

For your second point, I couldn't find that specific file in the bin of the mingw. I only fould 2 dlls there and I copied them into the lib folder in codeblocks, but I still get that same error message as before.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
(HELP!) I am having problems setting up SFML with Codeblock
« Reply #6 on: April 08, 2010, 10:13:58 pm »
Quote
For your first point, what does that even mean? OS? Do I need to fix it? Because I really don't know what dynamic library is, I was just trying to get my program to at least compiler and run.

Hmm, so maybe you should learn the basics first before trying to program?
-> what is a library, shared / static, what is the compiler, the linker, the different steps of creating a program, and who is involved at each step, etc.

Anyway, I meant that when you launch your application, the operating system (Windows) tries to locate the DLLs that your program is using (the SFML ones). And the operating system doesn't know about the lib folder to which you copied them, so it cannot find them. There's nothing to fix, just put the DLLs where the operating system can find them (in the same directory as the executable or in a directory which is on the PATH environment variable).

Quote
For your second point, I couldn't find that specific file in the bin of the mingw. I only fould 2 dlls there and I copied them into the lib folder in codeblocks, but I still get that same error message as before.

So I guess that you don't have MinGW with gcc 4.4. You need it to use SFML anyway (obviously not for the system module, but for the other ones), so you should download and install it (there is a link in the Code::Blocks tutorial).
Laurent Gomila - SFML developer

T-Trojan

  • Newbie
  • *
  • Posts: 9
    • View Profile
(HELP!) I am having problems setting up SFML with Codeblock
« Reply #7 on: April 08, 2010, 11:35:47 pm »
Quote from: "Laurent"
Quote
For your first point, what does that even mean? OS? Do I need to fix it? Because I really don't know what dynamic library is, I was just trying to get my program to at least compiler and run.

Hmm, so maybe you should learn the basics first before trying to program?
-> what is a library, shared / static, what is the compiler, the linker, the different steps of creating a program, and who is involved at each step, etc.

Anyway, I meant that when you launch your application, the operating system (Windows) tries to locate the DLLs that your program is using (the SFML ones). And the operating system doesn't know about the lib folder to which you copied them, so it cannot find them. There's nothing to fix, just put the DLLs where the operating system can find them (in the same directory as the executable or in a directory which is on the PATH environment variable).

Quote
For your second point, I couldn't find that specific file in the bin of the mingw. I only fould 2 dlls there and I copied them into the lib folder in codeblocks, but I still get that same error message as before.

So I guess that you don't have MinGW with gcc 4.4. You need it to use SFML anyway (obviously not for the system module, but for the other ones), so you should download and install it (there is a link in the Code::Blocks tutorial).


[off-topic] sorry took me a long time to extract the new version on the mem stick, and then fiddle around with the files again

[on-topic] IT COMPILES! OMGZ!

One thing though, at the top I used #include for window , system and iostream

however when I put this line into the program

sf::Window App(sf::VideoMode(800, 600, 32), "SFML OpenGL");

it gives me alot of errors.


-------------- Build: Debug in OpenGL ---------------

Compiling: main.cpp
Linking console executable: bin\Debug\OpenGL.exe
F:\CodeBlocks\MinGW\lib/libsfml-window.a(d000045.o)(.text+0x0): multiple definition of `sf::VideoMode::VideoMode(unsigned int, unsigned int, unsigned int)'
F:\CodeBlocks\MinGW\lib/libsfml-window-s.a(VideoMode.o)(.text+0x54):VideoMode.cpp: first defined here
F:\CodeBlocks\MinGW\lib/libsfml-window.a(d000025.o)(.text+0x0): multiple definition of `sf::Window::Window(sf::VideoMode, std::string const&, unsigned long, sf::WindowSettings const&)'
F:\CodeBlocks\MinGW\lib/libsfml-window-s.a(Window.o)(.text+0xee8):Window.cpp: first defined here
F:\CodeBlocks\MinGW\lib/libsfml-system.a(d000011.o)(.text+0x0): multiple definition of `sf::Clock::Clock()'
F:\CodeBlocks\MinGW\lib/libsfml-system-s.a(Clock.o)(.text+0x40):Clock.cpp: first defined here
F:\CodeBlocks\MinGW\lib/libsfml-system.a(d000058.o)(.text+0x0): multiple definition of `sf::Clock::GetElapsedTime() const'
F:\CodeBlocks\MinGW\lib/libsfml-system-s.a(Clock.o)(.text+0x14):Clock.cpp: first defined here
F:\CodeBlocks\MinGW\lib/libsfml-system.a(d000019.o)(.text+0x0): multiple definition of `sf::Sleep(float)'
F:\CodeBlocks\MinGW\lib/libsfml-system-s.a(Sleep.o)(.text+0x0):Sleep.cpp: first defined here
F:\CodeBlocks\MinGW\lib/libsfml-window-s.a(Window.o)(.text+0x799):Window.cpp: undefined reference to `_Unwind_Resume'
F:\CodeBlocks\MinGW\lib/libsfml-window-s.a(Window.o)(.text+0x7f9):Window.cpp: undefined reference to `std::basic_ostream<char, std::char_traits<char> >& std::__ostream_insert<char, std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&, char const*, int)'
F:\CodeBlocks\MinGW\lib/libsfml-window-s.a(Window.o)(.text+0x8e8):Window.cpp: undefined reference to `std::ctype<char>::_M_widen_init() const'
F:\CodeBlocks\MinGW\lib/libsfml-window-s.a(Window.o)(.text+0x91c):Window.cpp: undefined reference to `std::basic_ostream<char, std::char_traits<char> >& std::__ostream_insert<char, std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&, char const*, int)'
F:\CodeBlocks\MinGW\lib/libsfml-window-s.a(Window.o)(.text+0x9a0):Window.cpp: undefined reference to `std::basic_ostream<char, std::char_traits<char> >& std::__ostream_insert<char, std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&, char const*, int)'
F:\CodeBlocks\MinGW\lib/libsfml-window-s.a(Window.o)(.text+0x9e4):Window.cpp: undefined reference to `std::ctype<char>::_M_widen_init() const'
F:\CodeBlocks\MinGW\lib/libsfml-window-s.a(Window.o)(.text+0xaaa):Window.cpp: undefined reference to `_Unwind_Resume'
F:\CodeBlocks\MinGW\lib/libsfml-window-s.a(Window.o)(.text+0xb52):Window.cpp: undefined reference to `_Unwind_Resume'
F:\CodeBlocks\MinGW\lib/libsfml-window-s.a(Window.o)(.text+0xbfa):Window.cpp: undefined reference to `_Unwind_Resume'
F:\CodeBlocks\MinGW\lib/libsfml-window-s.a(Window.o)(.text+0xece):Window.cpp: undefined reference to `_Unwind_Resume'
F:\CodeBlocks\MinGW\lib/libsfml-window-s.a(Window.o)(.text+0x115e):Window.cpp: undefined reference to `_Unwind_Resume'
F:\CodeBlocks\MinGW\lib/libsfml-window-s.a(Window.o)(.text+0x1406):Window.cpp: more undefined references to `_Unwind_Resume' follow
F:\CodeBlocks\MinGW\lib/libsfml-window-s.a(Window.o)(.eh_frame+0x12):Window.cpp: undefined reference to `__gxx_personality_v0'
F:\CodeBlocks\MinGW\lib/libsfml-window-s.a(WindowImpl.o)(.text+0x625):WindowImpl.cpp: undefined reference to `_Unwind_Resume'
F:\CodeBlocks\MinGW\lib/libsfml-window-s.a(WindowImpl.o)(.text+0x686):WindowImpl.cpp: undefined reference to `_Unwind_Resume'
F:\CodeBlocks\MinGW\lib/libsfml-window-s.a(WindowImpl.o)(.text+0x6c3):WindowImpl.cpp: undefined reference to `_Unwind_Resume'
F:\CodeBlocks\MinGW\lib/libsfml-window-s.a(WindowImpl.o)(.text+0x94f):WindowImpl.cpp: undefined reference to `_Unwind_Resume'
F:\CodeBlocks\MinGW\lib/libsfml-window-s.a(WindowImpl.o)(.text+0x97b):WindowImpl.cpp: undefined reference to `_Unwind_Resume'
F:\CodeBlocks\MinGW\lib/libsfml-window-s.a(WindowImpl.o)(.text+0x9a7):WindowImpl.cpp: more undefined references to `_Unwind_Resume' follow
F:\CodeBlocks\MinGW\lib/libsfml-window-s.a(WindowImpl.o)(.eh_frame+0x12):WindowImpl.cpp: undefined reference to `__gxx_personality_v0'
F:\CodeBlocks\MinGW\lib/libsfml-window-s.a(VideoMode.o)(.eh_frame+0x11):VideoMode.cpp: undefined reference to `__gxx_personality_v0'
F:\CodeBlocks\MinGW\lib/libsfml-window-s.a(Context.o)(.text+0x108):Context.cpp: undefined reference to `_Unwind_Resume'
F:\CodeBlocks\MinGW\lib/libsfml-window-s.a(Context.o)(.eh_frame+0x12):Context.cpp: undefined reference to `__gxx_personality_v0'
F:\CodeBlocks\MinGW\lib/libsfml-window-s.a(WindowImplWin32.o)(.text+0x4e7):WindowImplWin32.cpp: undefined reference to `_Unwind_Resume'
F:\CodeBlocks\MinGW\lib/libsfml-window-s.a(WindowImplWin32.o)(.text+0xd08):WindowImplWin32.cpp: undefined reference to `_Unwind_Resume'
F:\CodeBlocks\MinGW\lib/libsfml-window-s.a(WindowImplWin32.o)(.text+0x121e):WindowImplWin32.cpp: undefined reference to `_Unwind_Resume'
F:\CodeBlocks\MinGW\lib/libsfml-window-s.a(WindowImplWin32.o)(.text+0x1346):WindowImplWin32.cpp: undefined reference to `_Unwind_Resume'
F:\CodeBlocks\MinGW\lib/libsfml-window-s.a(WindowImplWin32.o)(.text+0x146e):WindowImplWin32.cpp: undefined reference to `_Unwind_Resume'
F:\CodeBlocks\MinGW\lib/libsfml-window-s.a(WindowImplWin32.o)(.text+0x1584):WindowImplWin32.cpp: undefined reference to `std::basic_ostream<char, std::char_traits<char> >& std::__ostream_insert<char, std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&, char const*, int)'
F:\CodeBlocks\MinGW\lib/libsfml-window-s.a(WindowImplWin32.o)(.text+0x15cc):WindowImplWin32.cpp: undefined reference to `std::ctype<char>::_M_widen_init() const'
F:\CodeBlocks\MinGW\lib/libsfml-window-s.a(WindowImplWin32.o)(.text+0x1760):WindowImplWin32.cpp: undefined reference to `std::basic_ostream<char, std::char_traits<char> >& std::__ostream_insert<char, std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&, char const*, int)'
F:\CodeBlocks\MinGW\lib/libsfml-window-s.a(WindowImplWin32.o)(.text+0x17a3):WindowImplWin32.cpp: undefined reference to `std::ctype<char>::_M_widen_init() const'
F:\CodeBlocks\MinGW\lib/libsfml-window-s.a(WindowImplWin32.o)(.text+0x17d0):WindowImplWin32.cpp: undefined reference to `_Unwind_Resume'
F:\CodeBlocks\MinGW\lib/libsfml-window-s.a(WindowImplWin32.o)(.text+0x17d8):WindowImplWin32.cpp: undefined reference to `_Unwind_Resume'
F:\CodeBlocks\MinGW\lib/libsfml-window-s.a(WindowImplWin32.o)(.text+0x197c):WindowImplWin32.cpp: undefined reference to `std::basic_ostream<char, std::char_traits<char> >& std::__ostream_insert<char, std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&, char const*, int)'
F:\CodeBlocks\MinGW\lib/libsfml-window-s.a(WindowImplWin32.o)(.text+0x1c24):WindowImplWin32.cpp: undefined reference to `std::ctype<char>::_M_widen_init() const'
F:\CodeBlocks\MinGW\lib/libsfml-window-s.a(WindowImplWin32.o)(.text+0x1c5e):WindowImplWin32.cpp: undefined reference to `std::basic_ostream<char, std::char_traits<char> >& std::__ostream_insert<char, std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&, char const*, int)'
F:\CodeBlocks\MinGW\lib/libsfml-window-s.a(WindowImplWin32.o)(.text+0x1d02):WindowImplWin32.cpp: undefined reference to `std::ostream& std::ostream::_M_insert<unsigned long>(unsigned long)'
F:\CodeBlocks\MinGW\lib/libsfml-window-s.a(WindowImplWin32.o)(.text+0x1dd0):WindowImplWin32.cpp: undefined reference to `std::ctype<char>::_M_widen_init() const'
F:\CodeBlocks\MinGW\lib/libsfml-window-s.a(WindowImplWin32.o)(.text+0x1e0d):WindowImplWin32.cpp: undefined reference to `std::ctype<char>::_M_widen_init() const'
F:\CodeBlocks\MinGW\lib/libsfml-window-s.a(WindowImplWin32.o)(.text+0x225c):WindowImplWin32.cpp: undefined reference to `_Unwind_Resume'
F:\CodeBlocks\MinGW\lib/libsfml-window-s.a(WindowImplWin32.o)(.text+0x2624):WindowImplWin32.cpp: undefined reference to `_Unwind_Resume'
F:\CodeBlocks\MinGW\lib/libsfml-window-s.a(WindowImplWin32.o)(.text+0x273a):WindowImplWin32.cpp: undefined reference to `_Unwind_Resume'
F:\CodeBlocks\MinGW\lib/libsfml-window-s.a(WindowImplWin32.o)(.text+0x2852):WindowImplWin32.cpp: undefined reference to `_Unwind_Resume'
F:\CodeBlocks\MinGW\lib/libsfml-window-s.a(WindowImplWin32.o)(.text+0x2a92):WindowImplWin32.cpp: undefined reference to `_Unwind_Resume'
Process terminated with status 1 (0 minutes, 10 seconds)
50 errors, 0 warnings
 


But thanks alot on straightening me out, that's something I've b een struggling for 3 days now.

T-Trojan

  • Newbie
  • *
  • Posts: 9
    • View Profile
(HELP!) I am having problems setting up SFML with Codeblock
« Reply #8 on: April 09, 2010, 12:54:32 am »
nvm, I changed in the build options, removed the -s

and it worked. However, once again

// Set color and depth clear value
glClearDepth(1.f);
glClearColor(0.f, 0.f, 0.f, 0.f);

// Enable Z-buffer read and write
glEnable(GL_DEPTH_TEST);
glDepthMask(GL_TRUE);

// Setup a perspective projection
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluPerspective(90.f, 1.f, 1.f, 500.f);


put that in and it says that all of those "g" things are undefined references.

Breakman79

  • Jr. Member
  • **
  • Posts: 58
    • View Profile
(HELP!) I am having problems setting up SFML with Codeblock
« Reply #9 on: April 09, 2010, 01:26:53 am »
Those are regular OpenGL function calls.  Did you perhaps forget to include the OpenGL header files?

T-Trojan

  • Newbie
  • *
  • Posts: 9
    • View Profile
(HELP!) I am having problems setting up SFML with Codeblock
« Reply #10 on: April 09, 2010, 02:43:52 am »
EDIT: Actually, in the tutorial it says:

to use OpenGL, you only have to include Window.hpp : the OpenGL and GLU headers will be automatically included by it.

Breakman79

  • Jr. Member
  • **
  • Posts: 58
    • View Profile
(HELP!) I am having problems setting up SFML with Codeblock
« Reply #11 on: April 09, 2010, 02:53:43 am »
Well, there's your answer then.  Just add it in with the rest of your includes.

T-Trojan

  • Newbie
  • *
  • Posts: 9
    • View Profile
(HELP!) I am having problems setting up SFML with Codeblock
« Reply #12 on: April 09, 2010, 03:11:42 am »
-_-

Yeah I have #include<SFML/window.hbb>

and one for system and one for graphics just to be sure.

It gave me that error, now i am wondering what did I do wrong, cause everything else seems to work, just those G things.

Breakman79

  • Jr. Member
  • **
  • Posts: 58
    • View Profile
(HELP!) I am having problems setting up SFML with Codeblock
« Reply #13 on: April 09, 2010, 06:48:00 am »
Ahh, you need to add the OpenGL libraries to your linker.  In the same place in your IDE where you added the sfml-window.lib sfml-system.lib ect., try adding:

opengl32.lib
glu32.lib

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
(HELP!) I am having problems setting up SFML with Codeblock
« Reply #14 on: April 09, 2010, 07:41:56 am »
These are not compiler errors, but linker errors. Which means that it's not a problem with headers, but with libraries.
Laurent Gomila - SFML developer