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

Author Topic: [SOLVED]Problems Trying to use sf::CirlceShape and sf::Sound SFML 2.1  (Read 3849 times)

0 Members and 1 Guest are viewing this topic.

Giblit

  • Newbie
  • *
  • Posts: 11
    • View Profile
    • Email
Hello all,

I am having problems when I try and use
sf::CircleShape
and
sf::Sound
I have tried implicitly including the required headers.
#include <SFML/Graphics.hpp> //sf::CircleShape
#include <SFML/Audio.hpp> //sf::Sound

int main()
{
    sf::CircleShape Circle;
    sf::Sound Sound;
}
---
|6|error: 'CircleShape' is not a member of 'sf'|
|7|error: aggregate 'sf::Sound Sound' has incomplete type and cannot be defined|

and explicitly including them:

#include <SFML/Graphics/CircleShape.hpp> //sf::CircleShape
#include <SFML/Audio/Sound.hpp> //sf::Sound

int main()
{
    sf::CircleShape Circle;
    sf::Sound Sound;
}
---
|6|error: 'sf' has not been declared|
|7|error: 'sf' has not been declared|

The errors when I explicitly include make me wonder if I linked wrong. I statically linked sfml 2.1:





Any suggestions would be greatly appreciated.


*edit sorry forgot to mention earlier I am using Code::Blocks 12.11 with mingw gcc 4.7.1 with windows 7 not sure if any of this will affect the problem though.

**edit added audio link


« Last Edit: February 12, 2014, 12:03:21 am by Giblit »

Hapax

  • Hero Member
  • *****
  • Posts: 3351
  • My number of posts is shown in hexadecimal.
    • View Profile
    • Links
Re: Problems Trying to use sf::CirlceShape and sf::Sound SFML 2.1
« Reply #1 on: February 11, 2014, 08:59:15 pm »
First suggestion would be to add SFML's audio to the linker list.

Normally I'd then suggest you make sure your DLLs are in the correct directory but you're statically linking and it's not something I've done yet.
Selba Ward -SFML drawables
Cheese Map -Drawable Layered Tile Map
Kairos -Timing Library
Grambol
 *Hapaxia Links*

Giblit

  • Newbie
  • *
  • Posts: 11
    • View Profile
    • Email
Re: Problems Trying to use sf::CirlceShape and sf::Sound SFML 2.1
« Reply #2 on: February 11, 2014, 09:07:29 pm »
Thanks for the quick reply.
Not sure how I forgot to add the audio to linker. I just did it now but same problems. Also the only .dll you need when statically linking the the sound one which I included (.that I am aware of)
Quote
If you are using the sfml-audio module (either statically or dynamically), you must also copy the DLLs of the external libraries needed by it, which are libsndfile-1.dll and OpenAL32.dll.
http://sfml-dev.org/tutorials/2.1/start-cb.php

SLC

  • Newbie
  • *
  • Posts: 20
    • View Profile
Re: Problems Trying to use sf::CirlceShape and sf::Sound SFML 2.1
« Reply #3 on: February 11, 2014, 09:33:18 pm »
The thing is that you link to a static build of SFML therefore you will soon run into "undefined blah...blah" related problems.
  • When you link to the static SFML libraries (graphics, window, system) you must also link the following system libraries to your project: opengl32, glu32, kernel32, user32, gdi32, winspool, shell32, ole32, oleaut32, comdlg32, advapi32, winmm (I'm not sure about winmm)
  • Third party libraries that are also required by the static SFML libraries (graphics, window, system) and you must link to your project are: glew, freetype, jpeg
    Note: make sure to link Glew after SFML because sometimes you get "undefined blah...blah" messages that will make you hit your head against the walls without knowing what the problem is.
  • When you link to a static Glew build make sure to also define in your project: GLEW_STATIC
  • When you link to the static SFML network library (I think) you must also link your project to the following system libraries: ws2_32
  • When you link to the static SFML sound library you must also link the following third party libraries to your project: openal32, sndfile

Based on your current project you should link to the following libraries in the following order: opengl32, glu32, kernel32, user32, gdi32, winspool, shell32, ole32, oleaut32, comdlg32, advapi32, winmm, sfml-graphics-s, sfml-window-s, sfml-system-s, glew, freetype, jpeg . And define the following GLEW_STATIC if you link to the static Glew library inside SFML extlibs folder.

Your first attempt should work just fine however I can't figure out why it doesn't compile! Try to link to the specified libraries and see if it works :)
« Last Edit: February 11, 2014, 09:48:10 pm by SLC »

Giblit

  • Newbie
  • *
  • Posts: 11
    • View Profile
    • Email
Re: Problems Trying to use sf::CirlceShape and sf::Sound SFML 2.1
« Reply #4 on: February 11, 2014, 09:53:47 pm »
Thanks for the reply.
Quote
When you link to the static SFML sound library you must also link the following third party libraries to your project: openal32, sndfile
I have included these two dlls.

Quote
Based on your current project you should link to the following libraries in the following order: opengl32, glu32, kernel32, user32, gdi32, winspool, shell32, ole32, oleaut32, comdlg32, advapi32, winmm, sfml-graphics-s, sfml-window-s, sfml-system-s, glew, freetype, jpeg . And define the following GLEW_STATIC if you link to the static Glew library inside SFML extlibs folder.

I couldn't find any of these libraries. Where are they located at? I tried searching my entire computer for them with and without any extensions. The only ones found are dlls are you saying to include all those dlls to a project? because wouldn't that kind of defeat the purpose of statically linking when you have to include a lot more dlls than when you dynamically link it.

One more thing to mention I have them currently linked as:

graphics , sound , window , system instead of as graphics , window , system , sound because sound uses window I read.

SLC

  • Newbie
  • *
  • Posts: 20
    • View Profile
Re: Problems Trying to use sf::CirlceShape and sf::Sound SFML 2.1
« Reply #5 on: February 11, 2014, 10:12:24 pm »
opengl32, glu32, kernel32, user32, gdi32, winspool, shell32, ole32, oleaut32, comdlg32, advapi32, winmm are libraries that should be located in your MinGW folder.

glew.a, freetype.a, jpeg.a, openal32.a, sndfile.a are located in your SFML directory extlibs\libs-mingw\x86 but depending on your platform and compiler they might be located in a different directory under the extlibs folder.

One more thing to mention I have them currently linked as:

graphics , sound , window , system instead of as graphics , window , system , sound because sound uses window I read.

you can safely place sfml-sound after the three basic SFML (graphics, window, system) libraries.

Thanks for the reply.
Quote
When you link to the static SFML sound library you must also link the following third party libraries to your project: openal32, sndfile
I have included these two dlls.

I wasn't referring to the dll's I was referring to the libraries that allows you to use the code in those dll's (openal32.a, sndfile.a from SFML\extlibs\libs-mingw\x86).

When you compile SFML statically the compiler doesn't import the required static libraries into the SFML's static libraries. Therefore it's your job to link SFML's dependencies to your project if your project is an executable or dynamic link library (dll for short).
« Last Edit: February 11, 2014, 10:29:11 pm by SLC »

Giblit

  • Newbie
  • *
  • Posts: 11
    • View Profile
    • Email
Re: Problems Trying to use sf::CirlceShape and sf::Sound SFML 2.1
« Reply #6 on: February 11, 2014, 11:11:07 pm »
Hmm well I still can't find any of these libraries you are talking about I searched all the mingw folders and all of sfml folders. I re-installed codeblocks , sfml 2.1 , and re-linked everything and it worked. I am not sure what went wrong last time I have it linked exactly the same and it finds
Code: [Select]
sf::CircleShape and 
Code: [Select]
sf::Sound now. I am almost thinking that when I downloaded sfml last time a few of the files got corrupted somewhere. Thanks for all the help guys and sorry to have wasted your time I should have tried re-installing/linking everything earlier :(

Hapax

  • Hero Member
  • *****
  • Posts: 3351
  • My number of posts is shown in hexadecimal.
    • View Profile
    • Links
Re: Problems Trying to use sf::CirlceShape and sf::Sound SFML 2.1
« Reply #7 on: February 11, 2014, 11:39:50 pm »
I still can't find any of these libraries you are talking about I searched all the mingw folders and all of sfml folders.
They should be in your PATH. They should all end with .lib

Have you tried to run a window application that doesn't use SFML to help narrow it down?
Selba Ward -SFML drawables
Cheese Map -Drawable Layered Tile Map
Kairos -Timing Library
Grambol
 *Hapaxia Links*

 

anything