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

Author Topic: Is there anything I need to know before migrating my project to SFML 2.4.2?  (Read 5624 times)

0 Members and 3 Guests are viewing this topic.

codecodecode

  • Newbie
  • *
  • Posts: 26
    • View Profile
A while after starting my project I realised it's on an older SFML version, maybe 1.6. How can I migrate it seamlessly to the latest one, 2.4.2? On a 32-bit Linux. It looks like I'll have to compile it - http://www.sfml-dev.org/tutorials/2.4/compile-with-cmake.php - but what files should I repplace and what should I keep?
I don't remember anymore how or where I got this version of SFML from; maybe from an official repository?

My reason to think I'm on an older version is that some functions - text::setFillColor, text::setOutlineColor, text::setOutlineThickness - are apparently missing or not supported. Is this also the reason why no text is rendered below the first linebreak?

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11034
    • View Profile
    • development blog
    • Email
If you were using SFML 1.6, then you'd have to change a lot, but since you only mention a few missing functions you're probably just on an older 2.x version and thus changes are pretty much not needed.

The text not rendering might be, because SFML no longer ships a default font, so you'll have to provide your own and load it in your code.

Upgrading has the same process as starting bew, so check out the official tutorials and follow them.
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

codecodecode

  • Newbie
  • *
  • Posts: 26
    • View Profile
I was using 2.1, I think.

I built everything according to the tutorial (http://www.sfml-dev.org/tutorials/2.4/compile-with-cmake.php), all went smooth with no errors at the end, and yet when I tried to use those functions, I still got the error messages:
Quote
error: ‘class sf::Text’ has no member named ‘setFillColor’
error: ‘class sf::Text’ has no member named ‘setOutlineColor’
error: ‘class sf::Text’ has no member named ‘setOutlineThickness’
Relevant part of code, if that is of use:
                sf::Text txt("Error: tex is nullptr!",fonts[fontpath]);
                //....
                if(fillcolor!=nullptr)
                    txt.setFillColor(fillcolor->getData().getsfmlcolor());
                if(outlinecolor!=nullptr)
                    txt.setOutlineColor(outlinecolor->getData().getsfmlcolor());
                if(outlinethickness!=nullptr)
                    txt.setOutlineThickness(outlinethickness->getData());

Do I need to change something in the build options, like in the linker settings or in the search directories?

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11034
    • View Profile
    • development blog
    • Email
Well you need to replace the old files with the new ones, include directory, library files, dll files.
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

codecodecode

  • Newbie
  • *
  • Posts: 26
    • View Profile
It turns out I forgot to execute sudo make install. I don't know if that's the same, looks like it (if not, where do I see where are the old files to be replaced with which new ones?), here's the log:
(click to show/hide)

And there's progress - now I'm instead getting
Quote
undefined reference to `sf::Text::setFillColor(sf::Color const&)'|
undefined reference to `sf::Text::setOutlineColor(sf::Color const&)'|
undefined reference to `sf::Text::setOutlineThickness(float)'|

codecodecode

  • Newbie
  • *
  • Posts: 26
    • View Profile
Hmmm...
I set Search directories/Compiler path to [sfml build path]/src/SFML and Searc directories/Linker to [sfml build path]/lib (along with other necessary paths, like the ones for X11, cairo, pango, etc.) and now it compiles succesfully; but when I run it and open the window with SFML, it just closes immediately with
Quote
Process terminated with status 1 (0 minute(s), 1 second(s))
in the build log. Any idea what might be wrong this time?

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11034
    • View Profile
    • development blog
    • Email
Your code probably has a return 1 or similar statement in main(), for example when a resource doesn't load successfully.
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

codecodecode

  • Newbie
  • *
  • Posts: 26
    • View Profile
I replaced the old .hpp, .inl and .so files in /usr/include/SFML and /usr/lib/i386-linux-gnu with the new ones and changed back these two paths. I also rebuild everything. Essentially now the only difference with before is that I have the new 2.4.2 files instead of the old 2.1 and it closes immediately (without that build log message after the rebuild even). What else am I missing?

codecodecode

  • Newbie
  • *
  • Posts: 26
    • View Profile
Honestly I find all this very confusing. I followed the tutorials punctually and got that crash. I redeleted all .hpp and .so files, replaced them with freshly built 2.4.2 ones, recompiled and got that crash/immediate closure. I don't have return 1 anywhere in main; infact the first window without any sfml starts just fine, its when I open a child subwindow with sfml when it crashes. And it doesn't have a main function and it certainly doesn't return 1 anywhere on error.

Currently, I link to the following SFML files:
  • Search directories → Compiler has a record to /usr/include/SFML, which has the .hpp files, such as Config.hpp, Window.hpp, Graphics.hpp and System/Clock.hpp
  • Search directories → Linker has a record to /usr/lib/i386-linux-gnu, which has the .so files, such as libsfml-graphics.so, libsfml-graphics.so.2.4 and libsfml-graphics.so.2.4.2
All other settings and linked paths, search directores, etc. are the same as before, when it ran. What else do I need to link to? Perhaps the newer version requires some slightly different build settings?

It would be so much clearer if there was somewhere written what the end, running state of configuration looks like.

codecodecode

  • Newbie
  • *
  • Posts: 26
    • View Profile
Actually, are there any requierments for SFML 2.4.2? I certainly haven't seen any in the main page, but IIRC it uses OpenGL under the hood and my system only supports 1.4 or 2.1, can't remember exactly which.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
If you start to mess with several versions of the library, "random" way of installing what you built, etc. then you have 99% chances to get a compiler/linker/runtime error. If I were you, I'd first remove everything related to SFML, then reconfigure (a fresh build) with CMake, recompile it and "make install" it. Then you should end up with a single, clean installation of the latest SFML version.

From there, it's the usual way of using a library: tell the compiler the proper include path, tell the linker the proper link path and libraries to link, and everything should work fine when you compile and run your program.

Regarding OpenGL, it should be ok. If not, SFML should print a descriptive message in the error output.
Laurent Gomila - SFML developer

codecodecode

  • Newbie
  • *
  • Posts: 26
    • View Profile
Deleted everything, downloaded 2.4.2 anew, compiled and installed it. Search directories → Compiler points to /usr/local/include/SFML, which contains the .hpp files and Search directories → Linker points to /usr/local/lib, which contains the .so files.

Same story. When I recompile everything and run it, the first window opens just fine. When I click the button to open the SFML subwindow, everything closes on the spot. Both in debug and release.
When I run the release in the console, the button for the SFML subwindow doesn't do anything, it's as if it doesn't contain any code. Nothing happens.
When I try to run the debug version from the console, I get this without anything opening:
Quote
error while loading shared libraries: libsfml-graphics.so.2.4: cannot open shared object file: No such file or directory
even though libsfml-graphics.so.2.4 is in /usr/local/lib.

dabbertorres

  • Hero Member
  • *****
  • Posts: 505
    • View Profile
    • website/blog
/usr/local/* isn't always in your PATH variable by default.

I'd double check that.

codecodecode

  • Newbie
  • *
  • Posts: 26
    • View Profile
I first added export PATH=$PATH:/usr/local/lib to ~/.profile, logged out and then in, made some changes to the code, compiled it and ran it, only to get the exact same behaviour. Repeated the same with export PATH=$PATH:/usr/local to no avail.

I thought maybe moving the files to where they used to be installed by default would help, but then I recalled I already tried that with no success.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Try this:
export LD_LIBRARY_PATH=/usr/local/lib && ./your_executable
Laurent Gomila - SFML developer

 

anything