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

Author Topic: Creating Libraries with SFML  (Read 1557 times)

0 Members and 1 Guest are viewing this topic.

TheDuceCat

  • Newbie
  • *
  • Posts: 12
    • View Profile
Creating Libraries with SFML
« on: May 28, 2012, 01:06:19 am »
If I wanted to create a library to add some extra functionality to SFML, how would I go about doing that? How would my library link to the SFML the user of my library is linking to?

Liag

  • Newbie
  • *
  • Posts: 5
    • View Profile
    • Email
Re: Creating Libraries with SFML
« Reply #1 on: July 03, 2012, 02:59:27 pm »
You simply link to SFML as with a normal application, choosing to build a library instead.

If you are building the library dynamically, you simply need both the SFML libraries (along with the required external libraries) and your library when running a program using your library. The program only needs to link to your library in this case, since it automatically loads the SFML ones. SFML then loads the external libraries, etc.

If you are building it statically, the library doesn't actually do any direct linking to SFML, and any program using your library has to link to SFML as well. In this case, when using Windows only the external libraries OpenAL32 and libsndfile need to be present (using linker options -static-libgcc and -static-libstdc++).

On Windows, the static SFML libraries use a special way of compiling the dependencies so that you don't have to link them in subsequent projects, but this requires rather advanced usage of CMake and may be rather difficult. This is defined in SFML/cmake/Macros.cmake.

This should be possible on Linux as well, but it's not officially supported, since static linking is rather uncommon on the platform. It's pretty useful for a more specific library, though.

As far as I know, for OS X SFML only officially supports XCode/LLVM which typically uses dynamic linking. Using gcc, it should be the same as on Linux.

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11034
    • View Profile
    • development blog
    • Email
Re: Creating Libraries with SFML
« Reply #2 on: July 03, 2012, 03:04:38 pm »
You can take a look at Thor, which extends SFML with some functionalities, it's also using Aurora internally.
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/