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

Author Topic: Binding to C++ (Eclipse CDT - Mac os X)  (Read 4466 times)

0 Members and 1 Guest are viewing this topic.

souwanttocaude

  • Newbie
  • *
  • Posts: 3
    • View Profile
Binding to C++ (Eclipse CDT - Mac os X)
« on: May 04, 2018, 05:28:11 pm »
Morning,

First thing, I am new to SFML
Second, after running a basic example from the tutorial I got this linker error:
ld: library not found for -l/usr/local/lib/libsfml-graphics.2.4.1.dylib
clang: error: linker command failed with exit code 1 (use -v to see invocation)

invoking the compiler here:
g++ -L/usr/local/lib/ -o "graphSFMLInit"  ./src/graphSFMLInit.o   -l/usr/local/lib/libsfml-graphics.2.4.1.dylib -l/usr/local/lib/libsfml-window.2.4.1.dylib -l/usr/local/lib/libsfml-audio.2.4.1.dylib -l/usr/local/lib/libsfml-network.2.4.1.dylib -l/usr/local/lib/libsfml-system.2.4.1.dylib

I told the linker where to find those libs by settings :
Project Properties->C/C++ Build->Settings->Tool Settings->MacOS X C++ Linker->Libraries :
/usr/local/lib/libsfml-graphics.2.4.1.dylib
/usr/local/lib/libsfml-window.2.4.1.dylib
/usr/local/lib/libsfml-audio.2.4.1.dylib
/usr/local/lib/libsfml-network.2.4.1.dylib
/usr/local/lib/libsfml-system.2.4.1.dylib

Image attached
« Last Edit: May 04, 2018, 05:55:45 pm by souwanttocaude »

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 10819
    • View Profile
    • development blog
    • Email
Re: Binding to C++ (Eclipse CDT - Mac os X)
« Reply #1 on: May 04, 2018, 05:35:58 pm »
Does the file exist at the specified location?
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

souwanttocaude

  • Newbie
  • *
  • Posts: 3
    • View Profile
Re: Binding to C++ (Eclipse CDT - Mac os X)
« Reply #2 on: May 04, 2018, 05:51:03 pm »
 :) Yes the file exits at the specified location

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 10819
    • View Profile
    • development blog
    • Email
Re: Binding to C++ (Eclipse CDT - Mac os X)
« Reply #3 on: May 04, 2018, 06:09:07 pm »
Usually the approach with linking libraries is to point the -L flag to the library directory and then only specify the library name like -lsfml-graphics
However I'm unfamiliar with macOS and its dylib.
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

Hiura

  • SFML Team
  • Hero Member
  • *****
  • Posts: 4321
    • View Profile
    • Email
Re: Binding to C++ (Eclipse CDT - Mac os X)
« Reply #4 on: May 05, 2018, 02:14:25 pm »
Usually the approach with linking libraries is to point the -L flag to the library directory and then only specify the library name like -lsfml-graphics
However I'm unfamiliar with macOS and its dylib.
It applies as well to macOS and dylib/framework (with the later, use the -F and -framework flags, but it's the same).
SFML / OS X developer

souwanttocaude

  • Newbie
  • *
  • Posts: 3
    • View Profile
Re: Binding to C++ (Eclipse CDT - Mac os X)
« Reply #5 on: May 07, 2018, 11:55:34 pm »
Usually the approach with linking libraries is to point the -L flag to the library directory and then only specify the library name like -lsfml-graphics
However I'm unfamiliar with macOS and its dylib.
It applies as well to macOS and dylib/framework (with the later, use the -F and -framework flags, but it's the same).

You were right. I changed the command line to invoke the compiler with this:
g++ -std=c++1y -I/Library/Frameworks/sfml-graphics.framework -I/Library/Frameworks/sfml-window.framework -I/Library/Frameworks/sfml-audio.framework -I/Library/Frameworks/sfml-network.framework -I/Library/Frameworks/sfml-system.framework -I/Library/Frameworks/SFML.framework -O0 -g3 -Wall -c -fmessage-length=0 -Wno-attributes -MMD -MP -MF"src/graphSFMLInit.d" -MT"src/graphSFMLInit.o" -o "src/graphSFMLInit.o" "../src/graphSFMLInit.cpp"

Eclipse CDT is able to find SFML frameworks and now I moved on to a new problem! -sf- is an undefined symbol

Undefined symbols for architecture x86_64:
  "sf::CircleShape::CircleShape(float, unsigned long)", referenced from:

Hiura

  • SFML Team
  • Hero Member
  • *****
  • Posts: 4321
    • View Profile
    • Email
Re: Binding to C++ (Eclipse CDT - Mac os X)
« Reply #6 on: May 09, 2018, 07:59:09 am »
That's not how you link against frameworks... From `man clang` read what `-I` (search for -I<directory>) and `-F` (-F<directory>) are for, from `man ld` read what `-l`(-lto_library), `-L` (-Ldir) and `-framework` are for. This should help correctly link against SFML, or any other library for that matter.
SFML / OS X developer