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

Author Topic: sf::Music is running my cpu at 40-100%?  (Read 5422 times)

0 Members and 2 Guests are viewing this topic.

insomniac

  • Newbie
  • *
  • Posts: 13
    • View Profile
sf::Music is running my cpu at 40-100%?
« on: December 17, 2012, 08:20:47 am »
I'm using sfml 1.6, I am only about a week into using sfml and I'm having trouble with audio no matter what rout I go. I compiled the basic sf::Music and sf::Sound tutorials and even those simple programs run my cpu 40-90%. So today I downloaded irrklang to see if maybe it was a problem with my computer,code,bug or what not. I played the same .ogg file and my cpu maintained 0-4%.
Is there something specific the tutorial doesn't mention that I need to do or is this common issue?

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Re: sf::Music is running my cpu at 40-100%?
« Reply #1 on: December 17, 2012, 08:30:02 am »
You should try SFML 2.
Laurent Gomila - SFML developer

insomniac

  • Newbie
  • *
  • Posts: 13
    • View Profile
Re: sf::Music is running my cpu at 40-100%?
« Reply #2 on: December 17, 2012, 08:34:24 am »
Ok Ill give it a shot and post back. Thanks!

insomniac

  • Newbie
  • *
  • Posts: 13
    • View Profile
Re: sf::Music is running my cpu at 40-100%?
« Reply #3 on: December 17, 2012, 10:01:36 am »
Well I've been up over 24 hours so setting up my compiler was a fail, I thought I followed the tutorial to the T besides being uncertain of what 2.0 version I needed and then something about an sdk version!
 
Linking console executable: ..\Knights&Gulds.exe
..\obj\Release\src\audio.o:audio.cpp:(.text+0x3c): undefined reference to `_imp___ZN2sf5MusicC1Ev'
..\obj\Release\src\audio.o:audio.cpp:(.text+0x12a): undefined reference to `_imp___ZN2sf5MusicC1Ev'
..\obj\Release\src\audio.o:audio.cpp:(.text+0x324): undefined reference to `_imp___ZN2sf5Music12openFromFileERKSs'
..\obj\Release\src\audio.o:audio.cpp:(.text+0x338): undefined reference to `_imp___ZN2sf11SoundStream4playEv'
..\obj\Release\src\audio.o:audio.cpp:(.text+0x351): undefined reference to `_imp___ZN2sf11SoundStream4stopEv'
..\obj\Release\src\audio.o:audio.cpp:(.text+0x367): undefined reference to `_imp___ZN2sf11SoundStream5pauseEv'
..\obj\Release\src\display.o:display.cpp:(.text+0x40f): undefined reference to `_imp___ZN2sf6Window6createENS_9VideoModeERKSsjRKNS_15ContextSettingsE'
..\obj\Release\src\display.o:display.cpp:(.text+0x427): undefined reference to `_imp___ZN2sf6Window17setFramerateLimitEj'
..\obj\Release\src\display.o:display.cpp:(.text+0x92e): undefined reference to `_imp___ZN2sf5Image12loadFromFileERKSs'
..\obj\Release\src\display.o:display.cpp:(.text+0xf70): undefined reference to `_imp___ZN2sf5Image12loadFromFileERKSs'
..\obj\Release\src\display.o:display.cpp:(.text+0x10f2): undefined reference to `_imp___ZN2sf5Image12loadFromFileERKSs'
..\obj\Release\src\display.o:display.cpp:(.text+0x11bb): undefined reference to `_imp___ZN2sf5Image12loadFromFileERKSs'
..\obj\Release\src\display.o:display.cpp:(.text+0x1284): undefined reference to `_imp___ZN2sf5Image12loadFromFileERKSs'
..\obj\Release\src\display.o:display.cpp:(.text+0x134d): more undefined references to `_imp___ZN2sf5Image12loadFromFileERKSs' follow
..\obj\Release\src\display.o:display.cpp:(.text+0x1d05): undefined reference to `_imp___ZN2sf4FontD1Ev'
..\obj\Release\src\display.o:display.cpp:(.text+0x216f): undefined reference to `_imp___ZN2sf6Window6createENS_9VideoModeERKSsjRKNS_15ContextSettingsE'
..\obj\Release\src\display.o:display.cpp:(.text+0x2187): undefined reference to `_imp___ZN2sf6Window17setFramerateLimitEj'
..\obj\Release\src\display.o:display.cpp:(.text+0x268e): undefined reference to `_imp___ZN2sf5Image12loadFromFileERKSs'
..\obj\Release\src\display.o:display.cpp:(.text+0x2cd0): undefined reference to `_imp___ZN2sf5Image12loadFromFileERKSs'
..\obj\Release\src\display.o:display.cpp:(.text+0x2e52): undefined reference to `_imp___ZN2sf5Image12loadFromFileERKSs'
..\obj\Release\src\display.o:display.cpp:(.text+0x2f1b): undefined reference to `_imp___ZN2sf5Image12loadFromFileERKSs'
..\obj\Release\src\display.o:display.cpp:(.text+0x2fe4): undefined reference to `_imp___ZN2sf5Image12loadFromFileERKSs'
..\obj\Release\src\display.o:display.cpp:(.text+0x30ad): more undefined references to `_imp___ZN2sf5Image12loadFromFileERKSs' follow
..\obj\Release\src\display.o:display.cpp:(.text+0x3a65): undefined reference to `_imp___ZN2sf4FontD1Ev'
..\obj\Release\src\display.o:display.cpp:(.text+0x3ea2): undefined reference to `_imp___ZN2sf4FontD1Ev'
..\obj\Release\src\display.o:display.cpp:(.text+0x3ec3): undefined reference to `_imp___ZN2sf4FontD1Ev'
..\obj\Release\src\display.o:display.cpp:(.text+0x4302): undefined reference to `_imp___ZN2sf4FontD1Ev'
..\obj\Release\src\display.o:display.cpp:(.text+0x4323): undefined reference to `_imp___ZN2sf4FontD1Ev'
collect2: ld returned 1 exit status
Process terminated with status 1 (0 minutes, 1 seconds)
28 errors, 0 warnings
 


Edit: Well after looking at the errors I realized why I was getting them. I commented out some if the code that wasn't compatible with 2.0.
« Last Edit: December 17, 2012, 10:12:40 am by insomniac »

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11030
    • View Profile
    • development blog
    • Email
AW: sf::Music is running my cpu at 40-100%?
« Reply #4 on: December 17, 2012, 10:20:30 am »
It seems you're not linking the needed libraries (sfml-graphics, sfml-window, sfml-audio, sfml-system).
What compiler and IDE are you using?
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

insomniac

  • Newbie
  • *
  • Posts: 13
    • View Profile
Re: sf::Music is running my cpu at 40-100%?
« Reply #5 on: December 17, 2012, 10:28:24 am »
I'm using code blocks.
My linker settings: sfml-graphics sfml-window sfml-system sfml-audio.
My search directories: ..\include\SFML-2.0\include  which is the same as I had it set up for 1.6.

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11030
    • View Profile
    • development blog
    • Email
AW: Re: sf::Music is running my cpu at 40-100%?
« Reply #6 on: December 17, 2012, 10:33:21 am »
And you've also changed the library search path to /.../SFML-2.0/lib, or are you still linking the 1.6 libs?
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

insomniac

  • Newbie
  • *
  • Posts: 13
    • View Profile
Re: sf::Music is running my cpu at 40-100%?
« Reply #7 on: December 17, 2012, 10:50:07 am »
Nope I cleaned the libs and include folder and replaced everything.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Re: sf::Music is running my cpu at 40-100%?
« Reply #8 on: December 17, 2012, 10:54:27 am »
Can you upload your .cbp file?
Laurent Gomila - SFML developer

insomniac

  • Newbie
  • *
  • Posts: 13
    • View Profile
Re: sf::Music is running my cpu at 40-100%?
« Reply #9 on: December 17, 2012, 11:02:38 am »
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<CodeBlocks_project_file>
        <FileVersion major="1" minor="6" />
        <Project>
                <Option title="K&amp;G" />
                <Option pch_mode="2" />
                <Option compiler="gcc" />
                <Build>
                        <Target title="Release">
                                <Option output="..\Knights&amp;Gulds" prefix_auto="1" extension_auto="1" />
                                <Option working_dir="..\" />
                                <Option object_output="..\obj\Release\" />
                                <Option type="1" />
                                <Option compiler="gcc" />
                                <Option use_console_runner="0" />
                                <Compiler>
                                        <Add option="-std=c++0x" />
                                        <Add option="-Wall" />
                                        <Add option="-lgdi32" />
                                        <Add option="-DWIN32" />
                                        <Add directory="..\include" />
                                        <Add directory="..\src\" />
                                        <Add directory="..\src\container\" />
                                        <Add directory="..\src\fwd\" />
                                        <Add directory="..\" />
                                </Compiler>
                                <Linker>
                                        <Add option="-s" />
                                        <Add option="-lgdi32" />
                                        <Add option="-lopengl32" />
                                        <Add option="-lWininet" />
                                        <Add library="..\lib\WS2_32.Lib" />
                                        <Add library="winmm" />
                                        <Add library="..\lib\libpthreadGC2.a" />
                                </Linker>
                        </Target>
                </Build>
                <Compiler>
                        <Add option="-march=i586" />
                        <Add option="-std=c++0x" />
                        <Add option="-Wall" />
                        <Add option="-fno-inline" />
                        <Add option="-l ws2_32" />
                        <Add option="-lgdi32" />
                        <Add directory="..\include" />
                        <Add directory="..\src\" />
                        <Add directory="..\src\container\" />
                        <Add directory="..\src\fwd\" />
                        <Add directory="..\" />
                        <Add directory="..\lib" />
                        <Add directory="..\include\SFML-2.0\include" />
                </Compiler>
                <Linker>
                        <Add option="-lsfml-graphics" />
                        <Add option="-lsfml-window" />
                        <Add option="-lsfml-system" />
                        <Add option="-lsfml-audio" />
                        <Add directory="..\include\SFML-2.0\include" />
                </Linker>
                <Unit filename="..\src\audio.cpp" />
                <Unit filename="..\src\audio.hpp" />
                <Unit filename="..\src\config.cpp" />
                <Unit filename="..\src\config.hpp" />
                <Unit filename="..\src\console.cpp" />
                <Unit filename="..\src\console.hpp" />
                <Unit filename="..\src\container\algorithm.hpp" />
                <Unit filename="..\src\container\container.hpp" />
                <Unit filename="..\src\container\iterator.hpp" />
                <Unit filename="..\src\container\ptr_list.cpp" />
                <Unit filename="..\src\container\ptr_list.hpp" />
                <Unit filename="..\src\container\ptr_vector.cpp" />
                <Unit filename="..\src\container\ptr_vector.hpp" />
                <Unit filename="..\src\container\shared.cpp" />
                <Unit filename="..\src\container\shared.hpp" />
                <Unit filename="..\src\display.cpp" />
                <Unit filename="..\src\display.hpp" />
                <Unit filename="..\src\extra\ntservice.cpp" />
                <Unit filename="..\src\extra\ntservice.hpp" />
                <Unit filename="..\src\fwd\audio.hpp" />
                <Unit filename="..\src\fwd\console.hpp" />
                <Unit filename="..\src\fwd\display.hpp" />
                <Unit filename="..\src\fwd\input.hpp" />
                <Unit filename="..\src\fwd\map.hpp" />
                <Unit filename="..\src\fwd\packet.hpp" />
                <Unit filename="..\src\fwd\socket.hpp" />
                <Unit filename="..\src\input.cpp" />
                <Unit filename="..\src\input.hpp" />
                <Unit filename="..\src\main.cpp" />
                <Unit filename="..\src\map.cpp" />
                <Unit filename="..\src\map.hpp" />
                <Unit filename="..\src\packet.cpp" />
                <Unit filename="..\src\packet.hpp" />
                <Unit filename="..\src\shared.cpp" />
                <Unit filename="..\src\shared.hpp" />
                <Unit filename="..\src\socket.cpp" />
                <Unit filename="..\src\socket.hpp" />
                <Unit filename="..\src\stdafx.h" />
                <Unit filename="..\src\util.cpp" />
                <Unit filename="..\src\util.hpp" />
                <Extensions>
                        <code_completion />
                        <debugger />
                        <envvars />
                        <wxsmith version="1">
                                <gui name="wxWidgets" src="" main="" init_handlers="necessary" language="CPP" />
                        </wxsmith>
                </Extensions>
        </Project>
</CodeBlocks_project_file>

 

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Re: sf::Music is running my cpu at 40-100%?
« Reply #10 on: December 17, 2012, 11:10:23 am »
You have one set of settings for "Release" and one global set of settings, this is not very clean. The consequence is that you have duplicated settings, and missing settings.

You should rather:
- define all the common stuff in the global configuration (compiler and linker paths, common compiler flags, ...)
- define all the Debug specific stuff in "Debug"
- define all the Release specific stuff in "Release"

-lsfml-audio should be written before -lsfml-system, the order is important (as stated in the tutorial).

And, most important: you add "SFML-2.0\include" instead of "SFML-2.0\lib" in the linker search paths.
« Last Edit: December 17, 2012, 11:21:07 am by Laurent »
Laurent Gomila - SFML developer

insomniac

  • Newbie
  • *
  • Posts: 13
    • View Profile
Re: sf::Music is running my cpu at 40-100%?
« Reply #11 on: December 17, 2012, 11:12:42 am »
I wish I understood french  ;D! Guess Ill bring that to google translate.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Re: sf::Music is running my cpu at 40-100%?
« Reply #12 on: December 17, 2012, 11:18:16 am »
Oh my god :-[

Don't bother with Google translate, I'm going to fix this.
Laurent Gomila - SFML developer

insomniac

  • Newbie
  • *
  • Posts: 13
    • View Profile
Re: sf::Music is running my cpu at 40-100%?
« Reply #13 on: December 17, 2012, 11:27:05 am »
Kinda weird but not really I linked it like I did all my other libs and it compiled.
..\lib\libsfml-window.a
..\lib\libsfml-graphics.a
« Last Edit: December 17, 2012, 11:30:00 am by insomniac »

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11030
    • View Profile
    • development blog
    • Email
Re: sf::Music is running my cpu at 40-100%?
« Reply #14 on: December 17, 2012, 01:18:27 pm »
Have you now added the directory to libraries to your search path? Because it's missing in the cbp file posted.

Here is one of my Code::Blocks project file, which I often use and which works fine:
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<CodeBlocks_project_file>
        <FileVersion major="1" minor="6" />
        <Project>
                <Option title="Support" />
                <Option execution_dir="D:/Programming/CPP/Support/" />
                <Option pch_mode="2" />
                <Option compiler="gcc" />
                <Build>
                        <Target title="Debug">
                                <Option output="bin/Debug/Support" prefix_auto="1" extension_auto="1" />
                                <Option object_output="obj/Debug/" />
                                <Option type="1" />
                                <Option compiler="gcc" />
                                <Option use_console_runner="0" />
                                <Compiler>
                                        <Add option="-g" />
                                </Compiler>
                                <Linker>
                                        <Add library="sfml-graphics-d" />
                                        <Add library="sfml-window-d" />
                                        <Add library="sfml-audio-d" />
                                        <Add library="sfml-system-d" />
                                </Linker>
                        </Target>
                        <Target title="Release">
                                <Option output="bin/Release/Support" prefix_auto="1" extension_auto="1" />
                                <Option object_output="obj/Release/" />
                                <Option type="1" />
                                <Option compiler="gcc" />
                                <Option use_console_runner="0" />
                                <Compiler>
                                        <Add option="-O2" />
                                </Compiler>
                                <Linker>
                                        <Add option="-s" />
                                        <Add library="sfml-graphics" />
                                        <Add library="sfml-window" />
                                        <Add library="sfml-audio" />
                                        <Add library="sfml-system" />
                                </Linker>
                        </Target>
                </Build>
                <Compiler>
                        <Add option="-Wall" />
                        <Add directory="D:/Programming/libraries/SFML/include" />
                </Compiler>
                <Linker>
                        <Add directory="D:/Programming/libraries/SFML/lib" />
                </Linker>
                <Unit filename="Main.cpp" />
                <Extensions>
                        <code_completion />
                        <envvars />
                        <debugger />
                        <lib_finder disable_auto="1" />
                </Extensions>
        </Project>
</CodeBlocks_project_file>
 

Obviously if you'd use it, you'll need the specified paths.
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

 

anything