Home > Introductory, SFML, Tutorial > Creating a first SFML Project

Creating a first SFML Project

In my last post, I provided videos to show you how to build SFML 2.0 from the source in Visual Studio or Code::Blocks. I also provided some general textual instructions for the same purpose.

Well today I present to you two more videos: this time on how to make a first project using SFML 2.0 in Visual Studio or Code::Blocks. This will include configuring search directories and adding libraries to the linker list, as well as compiling some sample code.

Following are some basic textual instruction on this process. It is split into three sections:

  1. Visual Studio/Visual C++
  2. Code::Blocks
  3. General (this applies to both, and hopefully other IDEs too)

Microsoft Visual Studio / Microsoft Visual C++ Express

  1. Create a new empty project (File -> New -> Project, select Empty Project, click OK and follow the wizard)
  2. Add the SFML 2.0 header files path to the project’s include directories
    1. Go to Project -> Properties
    2. Select Configuration Properties -> VC++ Directories
    3. Set the configuration to All Configurations
    4. Click Include Directories, click the arrow on the right hand side and select Edit
    5. In the new window add a new directory to the list:
      • your-root-sfml-2-directory/include/
  3. Add the SFML 2.0 library files path to the project’s library directories
    1. Remain on the same screen as for step 2
    2. Click Library Directories, click the arrow on the right hand side and select Edit
    3. In the new window add a new directory:
      • your-root-sfml-2-directory/lib/
  4. Still in all configurations, but only if you want to link statically, define the SFML_STATIC macro
    1. Go to Configuration Properties -> C/C++ -> Preprocessor
    2. Click Preprocessor Definitions, click the arrow on the right hand side and select Edit
    3. In the resulting window, add SFML_STATIC to the list and click OK
  5. Add the libraries for debug configuration
    1. Change the configuration to Debug, confirming changes in the process
    2. Go to Configuration Properties -> Linker -> Input
    3. Click Additional Dependencies, click the arrow on the right and select Edit
    4. Add the following libraries if you want to link statically
      • sfml-graphics-s-d.lib
      • sfml-audio-s-d.lib
      • sfml-system-s-d.lib
      • sfml-window-s-d.lib
      • sfml-network-s-d.lib
    5. Add the following libraries if you want to link dynamically
      • sfml-graphics-d.lib
      • sfml-audio-d.lib
      • sfml-system-d.lib
      • sfml-window-d.lib
      • sfml-network-d.lib
    6. Click OK to finish
  6. Add the libraries for release configuration:
    1. Change the configuration to Release, confirming changes in the process
    2. Remain in the same area as before
    3. Again select Additional Dependencies, click the arrow on the right hand side and select Edit
    4. Add the following libraries if you want to link statically
      • sfml-graphics-s.lib
      • sfml-audio-s.lib
      • sfml-system-s.lib
      • sfml-window-s.lib
      • sfml-network-s.lib
    5. Add the following libraries if you want to link dynamically
      • sfml-graphics.lib
      • sfml-audio.lib
      • sfml-system.lib
      • sfml-window.lib
      • sfml-network.lib
    6. Click OK to finish
  7. Link to the appropriate version of the C runtime in both configurations.
    1. First, set configuration to debug and go to Configuration Properties -> C/C++ -> Code Generation and change Runtime Library
    2. If in the SFML 2.0 binaries build video, you linked statically to the C runtime (i.e. set STATIC_STD_LIBS to TRUE), choose Multithreaded Debug /MTd
    3. If you linked dynamically to the C runtime (i.e. set STATIC_STD_LIBS to FALSE) then chose Multithreaded Debug Dll /MDd
    4. If you are unsure which of the previous two instructions to follow, try 3. If that fails, do 2.
    5. Now change the configuration to release, and save changes in the process
    6. Change Runtime library to Multithreaded /MT if you linked statically to the C runtime, and Multithreaded Dll /MD if you linked dynamically
  8. If you want to link dynamically, you must put the corresponding dll files in your project directory:
    1. The debug dlls
      • sfml-graphics-d-2.dll
      • sfml-audio-d-2.dll
      • sfml-system-d-2.dll
      • sfml-window-d-2.dll
      • sfml-network-d-2.dll
    2. The release dlls
      • sfml-graphics-2.dll
      • sfml-audio-2.dll
      • sfml-system-2.dll
      • sfml-window-2.dll
      • sfml-network-2.dll
  9. Click OK to finish
  10. Add a source code file (In the Solution Explorer - usually on the left hand side in Visual C++ Express and the right in Visual Studio - right click Source Files, select Add -> New Item, then C++ File (.cpp), choose a name and click Add
  11. Whether linking dynamically or statically, if you are using audio functionality of SFML, you should also put the following other DLLs in your main project directory:
    • libsndfile-1.dll
    • openal32.dll
    • (they will be found in your-root-sfml-2-directory/extlibs/bin/x86 (32bit) or your-root-sfml-2-directory/extlibs/bin/x64 (64bit) – use the 32bit ones if you are unsure)

Code::Blocks

  1. Configure the search directories:
    1. Go to Settings -> Compiler and Debugger, select Global Compiler Settings, go to the Search Directories tab and finally the inner Compiler tab.
    2. Click Add and
      • type your-root-sfml-2-directory/include/
      • If you have any include paths for older versions of SFML, use the arrows on the right to move this one above them
    3. Click OK to confirm
    4. Go to the Linker tab, click Add again and enter
      • type your-root-sfml-2-directory/lib/
      • If you have any library paths for older versions of SFML, use the arrows on the right to move this one above them
    5. Click OK to confirm
  2. Create a new project by going to File -> New -> Project, selecting Empty Project and clicking Go
  3. Enter a title for your project, choose its location, click Next and finally click Finish
  4. If you want to link statically, define the SFML_STATIC macro in each configuration/target (Debug and Release)
    1. Go to Project -> Properties, click Project’s Build Options, select the Compiler settings tab, and finally the #defines sub tab
    2. Select the Debug target on the left hand side and enter SFML_STATIC in the box
    3. Change the target to Release, confirming changes in the process, and again enter SFML_STATIC in the box
  5. Add the libraries for debug configuration
    1. Change the configuration to Debug, confirming changes in the process
    2. Go to the Linker settings tab
    3. Click Add to add a library and enter the first of the appropriate names below, before clicking OK and repeating for the other libraries
      • For static builds in particular, pay attention to the order in which the libraries are given, as it does matter
    4. Add the following libraries if you want to link statically
      1. sfml-graphics-s-d
      2. sfml-audio-s-d
      3. sfml-window-s-d
      4. sfml-network-s-d
      5. sfml-system-s-d
    5. Add the following libraries if you want to link dynamically
      1. sfml-graphics-d
      2. sfml-audio-d
      3. sfml-window-d
      4. sfml-network-d
      5. sfml-system-d
  6. Add the libraries for release configuration:
    1. Change the configuration to Release, confirming changes in the process
    2. Remain in the same area as before
    3. Again click Add to one by one add the libraries, before confirming with OK
    4. Add the following libraries if you want to link statically
      1. sfml-graphics-s
      2. sfml-audio-s
      3. sfml-window-s
      4. sfml-network-s
      5. sfml-system-s
    5. Add the following libraries if you want to link dynamically
      1. sfml-graphics
      2. sfml-audio
      3. sfml-window
      4. sfml-network
      5. sfml-system
  7. Click OK to finish
  8. If you want to link dynamically, you must put the corresponding dll files in your project directory:
    1. The debug dlls
      1. sfml-graphics-d-2.dll
      2. sfml-audio-d-2.dll
      3. sfml-system-d-2.dll
      4. sfml-window-d-2.dll
      5. sfml-network-d-2.dll
    2. The release dlls
      1. sfml-graphics-2.dll
      2. sfml-audio-2.dll
      3. sfml-system-2.dll
      4. sfml-window-2.dll
      5. sfml-network-2.dll
  9. Whether linking dynamically or statically, if you are using audio functionality of SFML, you should also put the following other DLLs in your main project directory:
    • libsndfile-1.dll
    • openal32.dll
    • (they will be found in your-root-sfml-2-directory/extlibs/bin/x86 (32bit) or your-root-sfml-2-directory/extlibs/bin/x64 (64bit) – use the 32bit ones if you are unsure)

General

At this stage, you hopefully have a project set up ready for use with SFML, as well as a source file awaiting SFML code. Well we won’t discuss how to write SFML source code in today’s lesson, but if you want some sample code, you can copy and paste this in, and compile and run it!

#include <SFML/Graphics.hpp>

int main()
{
	sf::RenderWindow Window(sf::VideoMode(800, 600, 32), "SFML Sample Application");

	while (Window.isOpened())
	{
		sf::Event Event;
		while (Window.pollEvent(Event))
		{
			switch (Event.type)
			{
			case sf::Event::Closed:
				Window.close();
				break;
			default:
				break;
			}
		}

		Window.clear(sf::Color(0, 255, 255));
		Window.display();
	}

	return 0;
}
Note: If you are using only the graphics and windowing functionality of SFML, there is no need to link any of the other libraries – audio, network, system – nor to provide the corresponding dlls for a dynamic build. In fact remove whichever libraries you aren’t using, but bear in mind that if you are using the graphics module, then you also require the windowing module as well. And I suggest you always link the system library, as that is probably used in most if not all of the other modules.

Anyway, that’s all for now. See you next time!
About these ads
  1. 20.05.2011 at 09:43 | #1

    Hi. That was great. It’s good that you working with sfml-2 cuz I was working with sfml-1.6 a couple of months ago. I think you should keep this blog up because I’m always here since you worked pretty nice ! I can help you anyway. :)

    • 20.05.2011 at 09:49 | #2

      Thanks for the feedback – I agree that SFML 2.0 is the best choice. Given the differences in public interface between SFML1.6 and 2.0, it would not make sense to have people learning the old version now. Also, building with the makefile is in my experience much less problematic than using prebuilt binaries.

      I shall be continuing with this blog. I have exams right now, so posts will be minimal for a few weeks, but then I shall be back with more tutorials, as well as posts about the game engine I am making.

      And any help would be appreciated of course – if you have any suggestions, corrections to posts, or whatever, you can comment on the “Contact Me” page or email me (you’ll find the email address there too).

  2. 20.05.2011 at 10:21 | #3

    Tnx. Yeah exams… Me too. Alright then. I’ll contact you to your email.

  3. zander
    20.08.2011 at 05:18 | #4

    yeah thanks for this it realy helped another tut that helped me also was the one on the sfml page much thanks keep up the good work

    • 20.08.2011 at 09:19 | #5

      Yes, Laurent’s tutorial is pretty good. I aimed to make mine a little more specific, but unfortunately, this article somewhat outdated. I hope to rewrite it soon.

  4. megamuffin
    22.01.2012 at 19:38 | #6

    These tutorials are awesome :D

    Just wanted to point out that in the newer versions of SFML 2.0 Window.IsOpened() got changed to Window.IsOpen().

    • 22.01.2012 at 23:41 | #7

      Thanks! Yes, someone else recently notified me about that one. I did post an update here and on YouTube – http://sfmlcoder.wordpress.com/2012/01/19/sfwindowisopen/ – but alas I’ve not got round to changing it here. The whole article needs an overhaul, to be honest. It’ll happen eventually, but I’m otherwise engaged writing my very first mathematical physics research paper right now!

  5. Dislecix
    28.01.2012 at 22:47 | #8

    Been following your tutorials so far, and they’ve been helpful and I’ve been able to do everything so far, except on step 7 for the visual studios set up I get lost.

    “7. Link to the appropriate version of the C runtime in both configurations.”
    I can’t find out where to go to do so!

    • 29.01.2012 at 09:41 | #9

      Right. The setting should be under (in the configuration window) Configuration Settings -> C/C++ -> Code Generation. Then the setting is called ‘Runtime Library’.

      Is your problem that the “C/C++” tree doesn’t appear? For whatever reason, MS decided to hide it until you add a source file… so make sure you’ve added a source file (just an empty .cpp file will do) and try again.

  6. Lyle
    07.03.2012 at 23:59 | #10

    Hi, I followed your tutorial for Code::Blocks exactly how you said, but I still ended up with an error

    c:/mingw/bin/../lib/gcc/mingw32/4.6.2/../../../../mingw32/bin/ld.exe: final link failed: File truncated
    collect2: ld returned 1 exit status

    My project was working fine, but I recompiled SFML to get the static libs and I can’t seem to get them to work for the life of me. I compiled the libs successfully using Code::Blocks with MinGW and received no warnings or errors.
    I am linking to the libs in the correct order and have SFML_STATIC defined. Am I missing something here? I even reinstalled MinGW but that didn’t help.
    Also, when I try to compile my project in release mode, I get the message(from Windows) ld.exe has stopped working

    Any help would be greatly appreciated. This has been driving me crazy for days.

    • Lyle
      16.05.2012 at 20:47 | #11

      So I’m the only one who has experienced this problem?

      • 16.05.2012 at 20:52 | #12

        I’m sorry, I must have missed your comment. Are you still getting this comment with an up to date version of the source? Did you build the SFML binaries (static and dynamic) yourself as per my previous tutorial?

  7. 08.03.2012 at 02:46 | #13

    I just switched from Code::Blocks to Visual C++ 2010, and I can’t figure out how to get rid of the console window when compiling for release. I know there are Windows specific methods for hiding the console window, but in Code::Blocks its automatic, and I’m trying to keep my code as cross-platform compatible as possible. Sorry of this is a dumb question, I’m new to VC++.

    • 02.04.2012 at 08:14 | #14

      There isn’t an inherent cross platform way to do this, but SFML provides its own solution. On Windows, work with your project as a “Win32 Project”, or whatever it’s called. Normally, this would require you to #include &ltwindows.h&rt and write your main entry point as INT WINAPI WinMain(HINSTANCE, HINSTANCE, LPSTR, UINT) or something like that. But just go on ahead and write your entry point as normal: int main(int argc, char* args[]) or whatever.

      Now, here’s the important part. Obviously, by default, this causes a linking error since the linker is looking for the windows specific entry point. But if you link the SFML library sfml-main.lib (or sfml-main-d.lib) for debug configuration), then it will helpfully provide the WinMain entry point from your main entry point. Then, if you wanted to build it on, say, Ubuntu, you would just compile the exact same code (with the normal entry point), but just not link sfml-main.lib.

      Oh, and if you want to turn your existing project into a windows project, you can do as Andrew suggests. Simple go to Project Properties -> Linker -> System and change Subsystem to /SUBSYSTEM:WINDOWS. However, I think you do still need to follow the other steps above to avoid linker errors.

  8. Andrew
    18.03.2012 at 15:28 | #15

    I recently came across that problem as well. It’s a setting under project->properties

    configuration->release
    Configuration Properties->Linker->System->SubSystem->Windows (/SUBSYSTEM:WINDOWS)

  9. SuddenGun007
    02.04.2012 at 13:54 | #16

    Your tutorials on setting up SFML have been great, and saved me a ton of headache since I am just starting out with programming, my question is I followed your instructions exactly, but I don’t exactly know what you are doing (or more specifically why). I know my basic principles (loops,switchs,classes) but know absolutely nothing about the advanced settings of the ide, and minGW compiler. Will this knowledge come in time or should I just try to understand all of these details right now how did you come to learn how to build SFML using the cmd line, and all of those settings. Just overtime or did you just sit down and really learn it?

    • 02.04.2012 at 14:01 | #17

      I certainly didn’t just “sit down and learn it”. My initial tutorials showed you how to build the binaries with CMake’s GUI and an IDE. Then I learnt about makefiles and realised it would be better to do it on the command line. Even now, there are some improvements to add – I’m going to update the tutorials soon. So no, I certainly didn’t learn it all at once.

      That said, I don’t think it’s hard to understand. There just aren’t many references of which I know which put all the information in one place. I was hoping the videos helped to explain, but maybe it’s not clear enough. I’ll email you with a brief explanation now, and I’ll probably turn the email into a post about it later. But the important thing is, don’t be too concerned by what you don’t know. Computing is a massive, massive field and we’re only scratching the surface, so just take it slowly and persevere!

  10. SuddenGun007
    03.04.2012 at 08:06 | #18

    I thank you for for responding with such quickness and detail! I think what you emailed me, could probably benefit the masses who attempted SFML and gave up because they were confused on what exactly to do, and what you were doing in the tutorial

  11. Andrew
    16.05.2012 at 06:28 | #19

    Scratching my head a bit. I following along and built up SFML2 without a hitch, set up my project and hit a wall. I can’t compile your provided source code in Code::Blocks :

    ————– Clean: Debug in SFML Application —————

    Cleaned “SFML Application – Debug”

    ————– Build: Debug in SFML Application —————

    Compiling: main.cpp
    D:\Documents\SFML Application\main.cpp: In function ‘int main()’:
    D:\Documents\SFML Application\main.cpp:7: error: ‘class sf::RenderWindow’ has no member named ‘IsOpened’
    D:\Documents\SFML Application\main.cpp:10: error: ‘class sf::RenderWindow’ has no member named ‘PollEvent’
    D:\Documents\SFML Application\main.cpp:12: error: ‘class sf::Event’ has no member named ‘Type’
    D:\Documents\SFML Application\main.cpp:15: error: ‘class sf::RenderWindow’ has no member named ‘Close’
    D:\Documents\SFML Application\main.cpp:22: error: ‘class sf::RenderWindow’ has no member named ‘Clear’
    D:\Documents\SFML Application\main.cpp:23: error: ‘class sf::RenderWindow’ has no member named ‘Display’
    Process terminated with status 1 (0 minutes, 0 seconds)
    6 errors, 0 warnings

    I learned how to set up SDL to properly link, but I can’t figure out what I did wrong for SFML.

  12. Andrew
    16.05.2012 at 06:49 | #20

    Figured it out. There are some case sensitive errors to what I believe are methods. Here is the corrected code.

    #include

    int main()
    {
    sf::RenderWindow window(sf::VideoMode(800, 600, 32), “SFML Sample Application”);

    while (window.isOpen())
    {
    sf::Event Event;
    while (window.pollEvent(Event))
    {
    switch (Event.type)
    {
    case sf::Event::Closed:
    window.close();
    break;
    default:
    break;
    }
    }

    window.clear(sf::Color(0, 255, 255));
    window.display();
    }

    return 0;
    }

    • 16.05.2012 at 14:54 | #21

      Yes, SFML has undergone a lot of renaming: all functions and variables are now named in camelCase, i.e. first world all lowercase and subsequent words with initial captials.

      I think I posted about this at some point, but I haven’t had a chance to update all the tutorials yet. I’ll do this one now though, thanks for the reminder! :)

  13. Andrew
    16.05.2012 at 16:35 | #22

    I can see how keeping these tuts up to date with the SFML2.0 library could be daunting!
    I do thank you for your efforts. :)

    I’m coming to C++ from Python and so far I’ve spent more time figuring out all this compiler/linker/dynamic & static stuff. You’ve been a big help.

    • 16.05.2012 at 17:03 | #23

      Thanks! It is difficult, especially since I have exams on at the moment. However, now the SFML release candidate is out I’m guessing it’s basically ready for final release. At the very least, there probably won’t be many (if any) more public interface changes, so once I update the tutorials they should fit SFML 2 for good.

      As for dynamic and static linking, I explained that — along with a few other things — in a long email I wrote to a reader a while back. It’s not been edited enough to make it as a post yet, but I can email you a copy if you’re interested. :)

  14. 28.05.2012 at 23:20 | #24

    The project code should be updated, but the code from sfml-dev is current.

    #include

    int main()
    {
    sf::RenderWindow window(sf::VideoMode(300, 200,32), “SFML works!”);
    sf::Text text(“Hello World”);

    while (window.isOpen())
    {
    sf::Event event;
    while (window.pollEvent(event))
    {
    if (event.type == sf::Event::Closed)
    window.close();
    }

    window.clear(sf::Color(0, 0, 0));
    window.draw(text);
    window.display();
    }

    return 0;
    }

    • 30.05.2012 at 23:46 | #25

      Do you mean the project code in the videos? I haven’t had a chance to re-record them yet… The project code at the bottom of the post is correct for SFML 2.0, I think, though I may have missed one or two changes.

      My code isn’t identical to that on the official site, but I’m not too concerned by that. This tutorial is mainly about configuring your IDE to use SFML, the code is just a sample. Perhaps in the future I’ll make a more interesting example program.

  15. 30.06.2012 at 15:30 | #26

    I am having issues with linking and i’m fairly sure I followed the tutorial for setting up linked libraries correctly. What I get is the following:

    error LNK2001: unresolved external symbol “public: static class sf::RenderStates const sf::RenderStates::Default”

    I checked my settings and they appear in order.

    • 30.06.2012 at 15:51 | #27

      Okay, I know you followed the tutorial, but just to check, what are the names of the SFML libraries you’re linking? Also, what compiler/IDE are you using (Code::Blocks, Visual C++, etc)?

  16. Buzzer
    03.08.2012 at 07:34 | #28

    I followed this tutorial and set it up using the static ones, but if I try to compile the example program it gives me tons of “undefined reference to ‘sf::VideoMode’blah-blah “undefined refence to sf::RenderWindow” etc tons of undefined reference errors. I’m using CodeBlocks with SFML 2.0, and the example code I’m using doesn’t have any errors since it’s just from the official SFML page. Any ideas how to fix this problem??

    • 04.08.2012 at 16:02 | #29

      Have you correctly defined the SFML_STATIC macro?

      Also: With the compiler used by Code::Blocks (GCC on Linux/Unix, MinGW on Windows), it’s important to link static libraries in the correct order. Libraries should be above other libraries on which they depend. So the order of linkage should be:
      sfml-graphics-s
      sfml-window-s
      sfml-system-s

      (The sound and network libraries should also be above system if you use them.)

      Let me know if this helps with your issue!

      • Buzzer
        05.08.2012 at 05:08 | #30

        Yes. Your tutorial explains it very well, so I made sure to add SFML_STATIC and link them in the same order as you wrote. I couldn’t get it to work with CodeBlocks so I just followed another tutorial and got it to work with VC++. I wish there was one simple exe that would just install SFML though…

        • 05.08.2012 at 15:23 | #31

          I did make an executable installer a while back which installed the SFML libraries and optionally documentation and examples. The link is on my download page, but it hasn’t been updated for a while, so I don’t recommend using it for now (I’ll update it again soon). It didn’t set SFML up to work with Code::Blocks, though, if that’s what you meant.

          Just to clarify, did the undefined reference errors contain lots of @ symbols and other strange notation?

          • Buzzer
            05.08.2012 at 20:41 | #32

            Perhaps when SFML finishes version 2 completely then it’d be useful for a new exe installer that’d take care of everything. I remember it was such a pain to get it working at first, even following tutorials – or maybe all libraries are normally difficult to set up.
            I can’t remember what the errors were exactly, but I think there were lots of @ symbols in it.

            • 06.08.2012 at 10:17 | #33

              In that case it does sound like SFML_STATIC is wrongly defined. However if you have defined it, I’m not sure what to do about that.

              I think it’s possible to make a project template for Code::Blocks which has all these settings in it, so I’ll look into adding one of those to the executable installer in the future. Unfortunately I don’t think it’ll be as easy with Visual C++ Express.

  17. 25.08.2012 at 07:23 | #34

    Using Visual C++ Express I get errors in the source when compiling – ‘isOpened’ : is not a member of ‘sf::RenderWindow’. The code editor has under lined the .type after the Event class call and the isOpen, pollEvent, close and clear and the message when hovered over is . What have I done wrong?

    • 25.08.2012 at 07:25 | #35

      the message is sf::Event has no member “type. sorry for not adding that

    • 25.08.2012 at 10:50 | #36

      Are you using SFML 1.6 or SFML 2.0? These tutorials are for SFML 2.0, which has undergone substantial renaming. By this point you should definitely be using SFML 2.0 over 1.6 unless you are maintaining legacy projects already written with 1.6.

      If you’re already using SFML 2.0, perhaps you forgot to #include the SFML/Graphics.hpp header file?

      • 25.08.2012 at 11:41 | #37

        I’m using the SFML 2.0 prebuilt libraries that you provided, and the example source below the video (I did actually change isOpened to isOpen after reading an above comment). To clarify, I don’t know anything about SFML yet, as I’m encountering these problems when compiling the source in the video after just setting it up (which I’ve probably messed up somewhere). Also, thank you for the fast reply

  18. 11.12.2012 at 21:34 | #40

    Thanks for the help.

  1. 06.06.2011 at 15:03 | #1
  2. 15.06.2011 at 20:53 | #2
  3. 16.06.2011 at 20:38 | #3

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.

Join 72 other followers

%d bloggers like this: