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

Author Topic: std::unique_ptr on Mac  (Read 5883 times)

0 Members and 2 Guests are viewing this topic.

The Terminator

  • Full Member
  • ***
  • Posts: 224
  • Windows and Mac C++ Developer
    • View Profile
std::unique_ptr on Mac
« on: January 28, 2013, 07:45:12 pm »
Hi there, I've finally been able to link SFML 2.0 on my macbook pro. I'm trying to load my code that I've written on my Windows machine, but it seems that Xcode doesn't like std::unique_ptr. In fact, that's the only thing that Xcode is reporting as wrong.

My specs:
OS X 10.8.2
Macbook Pro
Xcode 4.5.2

Is there a bug or something with SFML? I can use std::unique_ptr on regular console applications. My code runs fine on my windows machine. Help is greatly appreciated.

Thanks
Current Projects:
Technoport

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11030
    • View Profile
    • development blog
    • Email
Re: std::unique_ptr on Mac
« Reply #1 on: January 28, 2013, 07:58:23 pm »
Have you set the compiler flag -std=c++11 and included <memory>?
What's the version of your compiler? (No Xcode is not a compiler, it's an IDE) ;)
« Last Edit: January 28, 2013, 09:13:57 pm by eXpl0it3r »
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

Nexus

  • SFML Team
  • Hero Member
  • *****
  • Posts: 6287
  • Thor Developer
    • View Profile
    • Bromeon
Re: std::unique_ptr on Mac
« Reply #2 on: January 28, 2013, 09:13:02 pm »
Have you set the compiler flag -c++11
For both clang and g++, the flag is -std=c++11 (or -std=c++0x in older versions).
Zloxx II: action platformer
Thor Library: particle systems, animations, dot products, ...
SFML Game Development:

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11030
    • View Profile
    • development blog
    • Email
Re: std::unique_ptr on Mac
« Reply #3 on: January 28, 2013, 09:14:34 pm »
For both clang and g++, the flag is -std=c++11 (or -std=c++0x in older versions).
That's what I've meant, thx. ;D
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: std::unique_ptr on Mac
« Reply #4 on: January 28, 2013, 10:58:28 pm »
To complement eXpl0it3r and Nexus here is the automatized way :

If you're using the lastest templates for Xcode (some details here), you can enable C++11 support easily. Choose «C++11 with Clang and libc++».

But remember : you need a compatible version of SFML. That is, you need to compile SFML with libc++ instead of libstdc++.

Read $C++11 here : http://www.sfml-dev.org/tutorials/2.0/start-osx.php
and Cmake tutorial here : http://www.sfml-dev.org/tutorials/2.0/compile-with-cmake.php
SFML / OS X developer

The Terminator

  • Full Member
  • ***
  • Posts: 224
  • Windows and Mac C++ Developer
    • View Profile
Re: std::unique_ptr on Mac
« Reply #5 on: January 28, 2013, 11:45:13 pm »
So there's no way to use c++11 with templates? I don't like cmake and it's given me a lot of trouble in the past.
Current Projects:
Technoport

Hiura

  • SFML Team
  • Hero Member
  • *****
  • Posts: 4321
    • View Profile
    • Email
Re: std::unique_ptr on Mac
« Reply #6 on: January 29, 2013, 01:52:54 pm »
Yes, there is. Maybe my previous sentence was not clear.

So to rephrase
Quote
If you're using the lastest templates for Xcode (some details here), you can enable C++11 support easily. Choose «C++11 with Clang and libc++».

When you create a new project with the latest templates for SFML, you can select a few options. To use C++11 in your project, select «C++11 with Clang and libc++» for «C++ Compiler and Standard Library». (Or, of course, you can change the settings of your current project to use clang and libc++.)

Regarding cmake, you should give it a try. It's not so difficult. ;-)
Here you can find the set of command that you'll need.
SFML / OS X developer