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

Author Topic: Linking libraries in MACOS  (Read 1815 times)

0 Members and 1 Guest are viewing this topic.

MainisHerelol

  • Newbie
  • *
  • Posts: 1
    • View Profile
    • Email
Linking libraries in MACOS
« on: November 22, 2024, 03:36:17 pm »
PLEASE HELP
Hi everyone,

I'm working on a C++ project using SFML (version 2.6.1) on macOS. The app works perfectly on my machine, but when I distribute it to others, it doesn't work as expected due to library linking issues. Here's the error I'm encountering:
objc[1404]: Class SFApplication is implemented in both /usr/local/Cellar/sfml/2.6.1/lib/libsfml-window.2.6.1.dylib and /Users/usernameismine/Desktop/C++ SFML game project/Bubble Popper.app/Contents/Frameworks/libsfml-window.2.6.1.dylib. One of the two will be used. Which one is undefined.


It looks like the unix exe (macos executable) is trying to load SFML from both the local installation (/usr/local/Cellar/sfml/...) and the app's bundled frameworks directory (.../Contents/Frameworks). This results in runtime conflicts.

Here’s what I’ve done:

I used g++ to compile the application.
I bundled the SFML libraries in the app package under Contents/Frameworks.
Added frameworks path in install_name_tool (@executable_name/../Frameworks) to the binary after compilation.
« Last Edit: November 22, 2024, 03:37:53 pm by MainisHerelol »

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11049
    • View Profile
    • development blog
    • Email
Re: Linking libraries in MACOS
« Reply #1 on: November 25, 2024, 09:34:56 am »
Is @executable_name/../Frameworks the right location then?
Meaning, is the excutable located somewhere in Bubble Popper.app/Contents/XYZ/MyExecutable?
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/