3

I copied the contents of Frameworks from SFML to ~/Library/Frameworks and tried to run the first tutorial example in SFML. I used this in g++ :

g++ -o sfml-test.cpp -framework SFML -lsfml-window

and get this error:

ld: framework not found SFML

Any help would be appreciated.

1 Answer 1

3

First of all, the tutorial specifies /Library/Frameworks, not ~/Library/Frameworks. ~ points to the user home directory (/Users/name/), whereas / points to the lowest point on the filesystem.

Also despite the documentation, /Library/Frameworks is not a standard framework directory, so you have to set it in the search paths. You can see the standard framework directories by running gcc -Xlinker -v:

@(#)PROGRAM:ld  PROJECT:ld64-409.12
BUILD 17:47:51 Sep 25 2018
configured to support archs: armv6 armv7 armv7s arm64 i386 x86_64 x86_64h armv6m armv7k armv7m armv7em arm64e arm64_32
Library search paths:
    /usr/local/lib
    /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/usr/lib
Framework search paths:
    /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/System/Library/Frameworks/
Undefined symbols for architecture x86_64:
  "_main", referenced from:
     implicit entry/start for main executable
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

Note the Framework search paths section, it does not include /Library/Frameworks.

To add /Library/Frameworks to the search path, compile with -F/Library/Frameworks and link with -F/Library/Frameworks -framework SFML -framework sfml-x, x being system, window, graphics, audio or network.

Also, the -o option specifies the output filename. Your command would take no input files and output the executable sfml-test.cpp, so use -o sfml-test sfml-test.cpp to take sfml-test.cpp as input, and output sfml-test.

Your command would be:

g++ -o sfml-test sfml-test.cpp -F/Library/Frameworks -framework SFML -framework sfml-window

Sign up to request clarification or add additional context in comments.

1 Comment

I tried that, but I get following error: ld: symbol(s) not found for architecture x86_64 clang: error: linker command failed with exit code 1 (use -v to see invocation)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.