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

Author Topic: Xcode and SFML2  (Read 5485 times)

0 Members and 1 Guest are viewing this topic.

zenkimoto

  • Newbie
  • *
  • Posts: 17
    • View Profile
Xcode and SFML2
« on: February 12, 2011, 08:01:56 pm »
Hi Everyone,

Pardon me for being a total noob.  :-)

Anyways, I downloaded the latest SFML from SVN.  (BTW, the sndfile.framework is corrupted (?) in the SVN version.  I fixed the symlinks and it still has problems.  I ended up using the 1.6 version instead)

So, I created the Xcode project using CMake.  I built the library and ran the "install" config (as admin).  It put the files in their appropriate locations (usr/local/include/SFML, usr/local/lib)

However, how do I setup a project in Xcode?  When I ended up doing was creating a project with the 1.6 template and removing the 1.6 sfml frameworks and adding the new dylib's.  I made sure the headers were in the search path.  However, nothing works.  How do I go about setting up a project in Xcode?  

Thanks for your help!

zenkimoto

  • Newbie
  • *
  • Posts: 17
    • View Profile
Xcode and SFML2
« Reply #1 on: February 13, 2011, 06:03:27 am »
Perhaps I wasn't descriptive enough :-)

I recreated a new project.  Since the headers and libraries have already been copied to /usr/local/lib and the headers are in /usr/local/include/SFML, Xcode seems to recognize it.  I added the dylib's (add existing framework) into my project: libsfml-audio.dylib, libsfml-graphics.dylib, libsfml-network.dylib, libsfml-system.dylib, and libsfml-window.dylib.

Then I created a RenderWindow as a test.  And this is what I get when I try the compile:

Code: [Select]

Undefined symbols:
  "sf::RenderWindow::RenderWindow(sf::VideoMode, std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, unsigned long, sf::WindowSettings const&)", referenced from:
      _main in main.o
ld: symbol(s) not found


I even added /usr/local/lib to my library and framework search paths and /usr/local/include/SFML to my header search paths.  Same problem...


It just errors out at this line:
Code: [Select]

sf::RenderWindow app(sf::VideoMode(800, 600), "SFML");



Thanks for anyone who can help...

devlin

  • Full Member
  • ***
  • Posts: 128
    • View Profile
Xcode and SFML2
« Reply #2 on: February 13, 2011, 09:37:40 am »
You usually shouldn't point it to /usr/local/include/SFML, as the includes are done with #include <SFML/Graphics.hpp> etc.

I haven't used XCode, but do make sure you include the libraries in the correct order.

Ceylo

  • Hero Member
  • *****
  • Posts: 2325
    • View Profile
    • http://sfemovie.yalir.org/
    • Email
Xcode and SFML2
« Reply #3 on: February 13, 2011, 12:13:28 pm »
Does the compiler says something about a wrong or missing architecture before displaying the undefined symbols?
Want to play movies in your SFML application? Check out sfeMovie!

zenkimoto

  • Newbie
  • *
  • Posts: 17
    • View Profile
Xcode and SFML2
« Reply #4 on: February 13, 2011, 04:15:05 pm »
Thanks guys for your replies!

@devlin

I agree.  I added the references to the search paths out of desperation, but it didn't make any difference.  So I removed them.

@Ceylo

You bring up a good point.  Apparently I compiled the libraries on my native architecture (x86_64).  When I switch my configuration to compile at x86_64, I still get the same undefined symbols error.  Obviously, when I switch it to a different architecture, I get the "file was built for unsupported file format..." error.  


Let me try and rebuild the libraries in the standard 32/64 bit format and see if that helps.  I will repost with the results.

Ceylo

  • Hero Member
  • *****
  • Posts: 2325
    • View Profile
    • http://sfemovie.yalir.org/
    • Email
Xcode and SFML2
« Reply #5 on: February 13, 2011, 04:20:09 pm »
You may just build your app for x86_64 architecture only. It's much easier (but I dunno whether you need to provide a universal app right now).
Want to play movies in your SFML application? Check out sfeMovie!

zenkimoto

  • Newbie
  • *
  • Posts: 17
    • View Profile
Xcode and SFML2
« Reply #6 on: February 13, 2011, 05:02:20 pm »
It appears to be the same error...

I just downloaded a fresh copy of SFML from SVN.  Did the whole cmake deal.  Compiled just fine and put the new libraries into /usr/local/lib, etc...
This time with the standard 32/64 bit.  Though I agree with you, it would be easier just to do my native architecture.  I didn't create a new project though, I just took my test project and remove/added the new libraries.  (Just to be safe)  And did a clean rebuild.  Ah well...

So, not sure what else to try now.  I could recompile with 64 bit and create a new project again...  I'll probably do that later.  Any other ideas?

Ceylo

  • Hero Member
  • *****
  • Posts: 2325
    • View Profile
    • http://sfemovie.yalir.org/
    • Email
Xcode and SFML2
« Reply #7 on: February 13, 2011, 05:48:07 pm »
Quote from: "zenkimoto"
This time with the standard 32/64 bit.

I dunno how you did this but... you should try to do the standard cmake build, with no specific option and just build your app for the x86_64 architecture ONLY.
Want to play movies in your SFML application? Check out sfeMovie!

Hiura

  • SFML Team
  • Hero Member
  • *****
  • Posts: 4321
    • View Profile
    • Email
Xcode and SFML2
« Reply #8 on: February 13, 2011, 09:14:04 pm »
I didn't read everything but did you use the step described here to create your project ? (Maybe it not complete enough and I should update it.)
SFML / OS X developer

zenkimoto

  • Newbie
  • *
  • Posts: 17
    • View Profile
Xcode and SFML2
« Reply #9 on: February 13, 2011, 10:12:59 pm »
@ceylo @Hiura

Thank you guys!  Anyways, I finally got it working.  Though the only way I was able to was to copy the dylib's into the project itself and added a build phase to copy it to the products directory.  

Hiura, darn I should have read the forums more thoroughly.  Those were the instructions I was looking for.  

Per your instructions, how do you do a sudo make install?  I tried to do that but I couldn't find the make files anywhere.  Do I do a sudo cmake install?  What I ended up doing was running Xcode as root (I know, bad bad) but I was able to build the dylibs and put them into /usr/local.

Hiura

  • SFML Team
  • Hero Member
  • *****
  • Posts: 4321
    • View Profile
    • Email
Xcode and SFML2
« Reply #10 on: February 13, 2011, 10:55:55 pm »
Quote from: "zenkimoto"
Per your instructions, how do you do a sudo make install?  I tried to do that but I couldn't find the make files anywhere.  Do I do a sudo cmake install?  What I ended up doing was running Xcode as root (I know, bad bad) but I was able to build the dylibs and put them into /usr/local.
That means you configured cmake to produce a project for Xcode, right ?
To run 'sudo make install' you have to set the target to Makefile.
In fact you only need Xcode for your project and not to compile SFML.
SFML / OS X developer

zenkimoto

  • Newbie
  • *
  • Posts: 17
    • View Profile
Xcode and SFML2
« Reply #11 on: February 15, 2011, 05:48:02 am »
@Hiura

I didn't know that you had to use the Unix make files instead of the Xcode project in CMake.  Let me give that a try.  

Thanks!

 

anything