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

Author Topic: undefined reference to `sf::Music::openFromFile  (Read 7606 times)

0 Members and 1 Guest are viewing this topic.

jaredcaruso

  • Newbie
  • *
  • Posts: 12
    • View Profile
undefined reference to `sf::Music::openFromFile
« on: March 17, 2016, 01:43:45 pm »
I'm using CodeLite. I am using "SFML 2.3.2 GCC 4.8.1 TDM (SJLJ) - 64-bit" from the download page. My library search path is "C:/SFML-2.3.1/lib", and SFML-2.3.1 is on my C drive. My compiler is MiniGW(TDM GCC 32). The include path is "C:/SFML-2.3.1/include". Precursors are SFML_STATIC. Basically, I set it up like the tutorial at:
http://en.sfml-dev.org/forums/index.php?topic=18820.0

The libraries in the linker setting looks like this:
sfml-graphics
sfml-window
sfml-audio
sfml-network
sfml-system


My code looks like this:
#include <iostream>
#include <SFML/Graphics.hpp>
#include <SFML/Audio.hpp>
using namespace std;

int sftest()
{
    sf::Music music;
    if (!music.openFromFile("research.ogg"))
        {
            //okkkkk
        }
    music.setPosition(0, 1, 10); // change its 3D position
    music.setPitch(2);           // increase the pitch
    music.setVolume(50);         // reduce the volume
    music.setLoop(true);         // make it loop
   
    music.play();
    return 0;
}  

sflab()
{
    system("cls");
    cout << "Welcome to the SFML Lab." << endl;
    sftest();
    return 0;
}
My log is here: http://pastebin.com/DENYQqu1
'research.ogg' is in the Debug folder of the Codelite project.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Re: undefined reference to `sf::Music::openFromFile
« Reply #1 on: March 17, 2016, 01:52:35 pm »
That's what you get for following non-official tutorials ;)

If you set SFML_STATIC, you must link to the variants of the libraries that have the -s suffix (sfml-graphics-s, etc.). Plus all the SFML dependencies.
Laurent Gomila - SFML developer

jaredcaruso

  • Newbie
  • *
  • Posts: 12
    • View Profile
Re: undefined reference to `sf::Music::openFromFile
« Reply #2 on: March 17, 2016, 01:55:02 pm »
How do I do that? I'm fairly new to coding and I the only tutorials I could find in the docs were for Visual Studio and Code::Blocks

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Re: undefined reference to `sf::Music::openFromFile
« Reply #3 on: March 17, 2016, 02:36:40 pm »
You can follow the tutorial for Code::Blocks, as long as you know where tu put the 3 project settings (include path, library path, libraries) the rest is the same and doesn't really depend on the IDE. In fact you're supposed to know how to set these basic settings in your IDE, it's not SFML's job to teach how to use CodeLite, Code::Blocks or Visual Studio ;)
Laurent Gomila - SFML developer

jaredcaruso

  • Newbie
  • *
  • Posts: 12
    • View Profile
Re: undefined reference to `sf::Music::openFromFile
« Reply #4 on: March 17, 2016, 02:38:11 pm »
My linked libraries are now:
sfml-graphics
sfml-window
sfml-audio
sfml-network
sfml-system
sfml-graphics-s
sfml-window-s
sfml-audio-s
sfml-network-s
sfml-system-s
opengl32
freetype
jpeg
winmm
gdi32
openal32
ws2_32
vorbis
vorbisenc
vorbisfile
flac
ogg


It still doesn't work and I get the same error. What else do I have to do?

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11034
    • View Profile
    • development blog
    • Email
Re: undefined reference to `sf::Music::openFromFile
« Reply #5 on: March 17, 2016, 02:50:39 pm »
Don't link dynamic AND static libraries.
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

jaredcaruso

  • Newbie
  • *
  • Posts: 12
    • View Profile
Re: undefined reference to `sf::Music::openFromFile
« Reply #6 on: March 17, 2016, 02:54:01 pm »
Don't link dynamic AND static libraries.

Which ones are static and which ones are dynamic? And do I only link the static ones?

bitano

  • Jr. Member
  • **
  • Posts: 89
    • View Profile
Re: undefined reference to `sf::Music::openFromFile
« Reply #7 on: March 17, 2016, 03:00:06 pm »
Don't link dynamic AND static libraries.

Which ones are static and which ones are dynamic? And do I only link the static ones?

Dynamic library: sfml-network
Static library: sfml-network-s

Notice the -s at the end of the library name :P. Remove those SFML libs without -s

jaredcaruso

  • Newbie
  • *
  • Posts: 12
    • View Profile
Re: undefined reference to `sf::Music::openFromFile
« Reply #8 on: March 17, 2016, 03:40:14 pm »
I linked only
sfml-graphics-s
sfml-window-s
sfml-audio-s
sfml-network-s
sfml-system-s

And now I have this error: http://pastebin.com/gMTq9WUw

And would it be better to do this dynamically? How would I do that instead?
« Last Edit: March 17, 2016, 03:49:35 pm by jaredcaruso »

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Re: undefined reference to `sf::Music::openFromFile
« Reply #9 on: March 17, 2016, 05:26:36 pm »
Every question that you ask is clearly answered in the "getting started" tutorial. Please read it carefully.
Laurent Gomila - SFML developer

jaredcaruso

  • Newbie
  • *
  • Posts: 12
    • View Profile
Re: undefined reference to `sf::Music::openFromFile
« Reply #10 on: March 17, 2016, 06:54:02 pm »
I installed Code::Blocks and did everything it says to do. My 5 libraries I linked are
sfml-graphics-d
sfml-window-d
sfml-audio-d
sfml-network-d
sfml-system-d

It still doesn't work with when I use the same code as before. It's currently set in debug and I copied all the DLL files from the sfml/bin folder to the debug folder in the code blocks project that has the executable. Also, I didn't set put SFML_STATIC this time so it can be dynamic or whatever

This is my error: http://pastebin.com/rAJ6aJSL
« Last Edit: March 17, 2016, 06:56:08 pm by jaredcaruso »

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11034
    • View Profile
    • development blog
    • Email
Re: undefined reference to `sf::Music::openFromFile
« Reply #11 on: March 17, 2016, 07:08:04 pm »
I am using "SFML 2.3.2 GCC 4.8.1 TDM (SJLJ) - 64-bit" ... My compiler is MiniGW(TDM GCC 32). ....
Hmmm ::)

Your compiler has to exactly match the compiler that was used to build the SFML package you downloaded. Otherwise just build SFML with your current compiler.
« Last Edit: March 17, 2016, 07:14:50 pm by eXpl0it3r »
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

jaredcaruso

  • Newbie
  • *
  • Posts: 12
    • View Profile
Re: undefined reference to `sf::Music::openFromFile
« Reply #12 on: March 17, 2016, 10:51:06 pm »
I downloaded and did the same stuff for the 32 bit one but it still doesn't work and I get the same errors :(

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11034
    • View Profile
    • development blog
    • Email
Re: undefined reference to `sf::Music::openFromFile
« Reply #13 on: March 18, 2016, 12:27:58 am »
Well is your compiler really TMD GCC 4.8.1 32bit?
And did you do a clean rebuild?
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

Arcade

  • Full Member
  • ***
  • Posts: 230
    • View Profile
Re: undefined reference to `sf::Music::openFromFile
« Reply #14 on: March 18, 2016, 03:44:05 pm »
I'm using CodeLite. I am using "SFML 2.3.2 GCC 4.8.1 TDM (SJLJ) - 64-bit" from the download page. My library search path is "C:/SFML-2.3.1/lib" ... The include path is "C:/SFML-2.3.1/include".

This was confusing to me. You said you downloaded 2.3.2, but then set up the lib and include search paths to a folder called 2.3.1? Did you just rename the 2.3.2 folder to 2.3.1, or are you using something different than what you downloaded?