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

Author Topic: Linking on Mac OS X  (Read 4297 times)

0 Members and 1 Guest are viewing this topic.

xqbt

  • Newbie
  • *
  • Posts: 30
    • View Profile
Linking on Mac OS X
« on: January 05, 2016, 12:43:22 am »
After setting everything up on my Windows machine, I thought Mac OS X would be a breeze. Naive me...
So, I am stuck at the  linking stage. Here is the complain statement:
Quote
==== Building new (debug) ====
main.cpp
Linking new
Apple LLVM version 5.1 (clang-503.0.40) (based on LLVM 3.4svn)
Target: x86_64-apple-darwin12.3.0
Thread model: posix
 "/usr/bin/ld" -demangle -dynamic -arch x86_64 -macosx_version_min 10.8.0 -o ./new -L../lib/SFML/macosx/Frameworks -L. obj/Debug/main.o -framework sfml-graphics -framework sfml-window -framework sfml-system -framework freetype -lstdc++ -lSystem /usr/bin/../lib/clang/5.1/lib/darwin/libclang_rt.osx.a
Undefined symbols for architecture x86_64:
  "std::__1::locale::locale()", referenced from:
      _main in main.o
  "std::__1::locale::~locale()", referenced from:
      _main in main.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
The program itself is a main file which creates a window.
Here is what I have done so far:
  • Downloaded official SFML package fop Mac OS from http://www.sfml-dev.org/download/sfml/2.3.2/
  • Following the instructions on http://www.sfml-dev.org/tutorials/2.2/start-osx.php, I copied all the listed frameworks (all from SFML/Frameworks + SFML/extlibs/freetype.framework) to /Library/Frameworks except sndfile.framework. I could not find it anywhere in the SFML package (I suppose snd means "sound", so do I need it?).
  • tried -m32, -stdlib=libc++, -std=c++11 and the combinations of those
  • banged my head on the keyboard
Please help.
PS I am using premake for creating makefiles, but I do not think it will bring any new info.
« Last Edit: January 05, 2016, 12:46:11 am by xqbt »

SpeCter

  • Full Member
  • ***
  • Posts: 151
    • View Profile
Re: Linking on Mac OS X
« Reply #1 on: January 05, 2016, 01:36:34 am »
Not sure if it helps/changes a thing but using the most recent version of the tutorial might help:
http://www.sfml-dev.org/tutorials/2.3/start-osx.php

xqbt

  • Newbie
  • *
  • Posts: 30
    • View Profile
Re: Linking on Mac OS X
« Reply #2 on: January 05, 2016, 02:26:38 am »
SpeCter, yeah, I guess those two articles (2.2 and 2.3) aren't very different, but thanks for the reply  :)
I have a strong feeling that something somewhere went very very wrong...
« Last Edit: January 05, 2016, 03:25:05 am by xqbt »

Hapax

  • Hero Member
  • *****
  • Posts: 3379
  • My number of posts is shown in hexadecimal.
    • View Profile
    • Links
Re: Linking on Mac OS X
« Reply #3 on: January 05, 2016, 03:49:08 am »
those two articles (2.2 and 2.3) aren't very different
True, but using the wrong one explains this:
... except sndfile.framework. I could not find it anywhere in the SFML package (I suppose snd means "sound", so do I need it?)
;)
Selba Ward -SFML drawables
Cheese Map -Drawable Layered Tile Map
Kairos -Timing Library
Grambol
 *Hapaxia Links*

xqbt

  • Newbie
  • *
  • Posts: 30
    • View Profile
Re: Linking on Mac OS X
« Reply #4 on: January 05, 2016, 04:03:51 am »
Hapax, yes, indeed. Well, there dies another hope of mine for an easy fix.

...

Tried linking dylibs instead of frameworks (removed freetype.framework too) so that now I am linking only graphics, window and system. Same error.
« Last Edit: January 05, 2016, 04:15:20 am by xqbt »

xqbt

  • Newbie
  • *
  • Posts: 30
    • View Profile
Re: Linking on Mac OS X
« Reply #5 on: January 05, 2016, 04:30:40 am »
Another piece of puzzle.
This code works:
#include "../lib/SFML/linux/include/SFML/System.hpp"

int main()
{
    sf::Clock c;

    return 0;
}
And this code brings the aforementioned errors:
#include "../lib/SFML/linux/include/SFML/Window.hpp"

int main()
{
    sf::Window w(sf::VideoMode(800, 600), "Test");

    return 0;
}
 

...

Am I missing a dependency somewhere? Window relies only upon the system, right?

...

BTW, I don't have Xcode installed, only command line developer tools. Could that be a problem?
And how is OpenGL linked, anyways?
« Last Edit: January 05, 2016, 01:45:30 pm by xqbt »

xqbt

  • Newbie
  • *
  • Posts: 30
    • View Profile
Re: Linking on Mac OS X
« Reply #6 on: January 05, 2016, 11:52:04 pm »
SOLVED!
The solution was to supply "-stdlib=libc++" flag to the linker (along with "-stdlib=libc++" and "-std=c++11" flags to the compiler).
Thanks all, especially to Deepak for his answer to his own question, which lead me to the solution:
http://stackoverflow.com/questions/19521398/linker-error-while-building-clang-using-makefile-with-a-checker