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

Author Topic: Compiling SFML on Mac OS X - Help  (Read 4161 times)

0 Members and 2 Guests are viewing this topic.

Enchanted Dragon

  • Newbie
  • *
  • Posts: 2
    • View Profile
Compiling SFML on Mac OS X - Help
« on: April 11, 2015, 04:18:27 am »
Hi, I am having trouble with SFML on my Mac. I did eventually get SFML working, but the method of doing so was a pain and I don't want to waste time typing a long command into terminal, rather than just hitting the run button in my IDE, eclipse. I understand all of this framework stuff, having to put the framework files into my '/Library/Frameworks' folder, etc. I did get it working, but through command-line on some "a.out" file, from the following commands:
Code: [Select]
cd (path to my project folder)

g++ Test.cpp -I (path to the "include" folder of SFML to properly include those files) -framework (sfml-xxx) (continued to include the system, window and graphics, and SFML framework)

Once that was done, I found a file, "a.out" was produced in my project folder. I ran it, and my SFML test window appeared as I intended it to. However, a .out file?

Any help would be appreciated, especially to fully compile this into a "Test.app" file. Also, any help on support .deb and .exe files for Linux and Windows support would be greatly appreciated as well. I use the Mac OS X compiler, which I suspect I should use the Cross CGG compiler.

Also, I don't understand something... the frameworks. I compile the needed frameworks into the file... right? Then, the file didn't run because of some graphics library missing or whatever the error message said, and I took the freetype framework file and put it in '/Library/Frameworks' in which, the program then worked properly, and I got my test window that opened. This is something I don't understand - What about Windows and Linux support with the ferrotype framework? One more thing, other Mac users wanting to play my SFML program would have to go through the bothersome of moving a freetype framework file into their Frameworks folder? I would imagine those things are compiled into the actual .app, .deb, and .exe files instead, right? I would imagine all of this would just run from a .app/.deb/.exe file, as it should be packed inside it properly. I do not understand this very well, a fine explanation of how it all works would be really helpful.

I hope to get a reply soon, to help me out. Additional information:

Operating System:
Mac OS X Yosemite

SFML Version:
2.2 (latest)

Development IDE:
Eclipse

Programming Language:
C++

One more thing: I would like to be able to build/run my program straight from Eclipse by hitting the Build button and the Run button, so if you know how to do that properly, I would appreciate that as well. I believe I would have to edit settings in the Build properties/configuration.

I thank you all for your help.

Hiura

  • SFML Team
  • Hero Member
  • *****
  • Posts: 4321
    • View Profile
    • Email
Re: Compiling SFML on Mac OS X - Help
« Reply #1 on: April 11, 2015, 02:36:37 pm »
Once that was done, I found a file, "a.out" was produced in my project folder. I ran it, and my SFML test window appeared as I intended it to. However, a .out file?

It has nothing to do with SFML, that's just the default output file. `man g++` should say something about -o I believe.


Any help would be appreciated, especially to fully compile this into a "Test.app" file.

I think you should read up on what exactly are application bundle and then look for a eclipse plugin that does it for you. It is tricky. Note that if you plan to distribute your application on the Apple Store you probably won't succeed without using Xcode. If you just want to distribute your app via more common medium, you probably still want to be able to sign it (otherwise it won't run on other people's computer without changing the OS security setting). Again, know the limitations of eclipse before attempting to use it for generating application bundle. You probably won't find mac user around here that use eclipse for that kind of stuff.


Also, any help on support .deb and .exe files for Linux and Windows support would be greatly appreciated as well. I use the Mac OS X compiler, which I suspect I should use the Cross CGG compiler.

Cross compiling is really hard and is probably not the best solution at all. Setting up some virtual machines is way much simpler and probable more stable, too. Also, deb files is probably not what you think it is... Basically, it's an archive used to install your application on someone debian-like system, not running it.


Then, the file didn't run because of some graphics library missing or whatever the error message said, and I took the freetype framework file and put it in '/Library/Frameworks' in which, the program then worked properly, and I got my test window that opened.

Frameworks, in a nutshell, are simply dylibs (or lib/dll/so files, depending on your system), or, generally speaking, "libraries". If a library has a dependency toward another one (like sfml-graphics has one towards freetype) you need to install that dependency too.

(Yes, you can embed other libraries into what's called an "umbrella" framework but Apple does not recommend that strategy.)


One more thing, other Mac users wanting to play my SFML program would have to go through the bothersome of moving a freetype framework file into their Frameworks folder?

Not if you create an application bundle (see getting started tutorial for mac, even if you don't use Xcode you'll find some interesting information there) and that you embed every dependency of your application in it.


One more thing: I would like to be able to build/run my program straight from Eclipse by hitting the Build button and the Run button, so if you know how to do that properly, I would appreciate that as well. I believe I would have to edit settings in the Build properties/configuration.

You should probably seek for help about C++ and Eclipse in general on a dedicated forum; I know how to use it for Scala and Java development but that's it.
SFML / OS X developer

Enchanted Dragon

  • Newbie
  • *
  • Posts: 2
    • View Profile
Re: Compiling SFML on Mac OS X - Help
« Reply #2 on: April 11, 2015, 07:16:23 pm »
Hi, thanks for your reply! However this adds to my confusion. I know most games use C++ for high performance and better stability, but how can something be good if cross compilation is not supported? I would rather not set up a virtual machine, as the performance is slow, it's a waste of time (especially downloading the iso file, it takes an HOUR), and it takes storage/memory off of my main hard drive. Also, I would prefer not to use Xcode, because it asks me to make some kind of specific application, such as a command-line tool, cocoa application, game, etc. which I dislike. In eclipse, however, it just lets me code the whole thing without limitations. Also, eclipse is more popular, and I don't know why it isn't documented in the SFML docs.

SFML stands for "Simple and Fast Multimedia Library". However, I strongly disagree on the "simple" part of it. I did want to make some cool 2D games in SFML, but now it's barely even possible to do so, especially supporting multiple operating systems. I did not just ask for explanations, I also asked for a guide, so a guide on how to do all of this through mac and eclipse would be wonderful. The fact that SFML uses "frameworks" makes it really hard to use, especially for having multiple users be able to use the SFML games you make. I don't want to have to make them install a bunch of framework files and put them somewhere, i want them to just be able to run the application. This is the same for Linux and Windows users, I was beginning to believe C++ was my favorite language, but now it's getting to be a real pain, and I'm starting to hate it in fact, because of it's low cross platform support.

I even know a game engine that's made in C++, and it easily supports the 3 operating systems. The way SFML works? It just makes it impossible to support multiple operating systems, and I hate that. Just why does is have to use frameworks? Why can't SFML be true to it's name and be "simple"?

Also, I'm asking for all the answers here, because this is related to SFML, maybe someone tells me how to build it on eclipse one way, and especially they will just tell me that it's already set up with the "make" command, and won't help me out. This is related to SFML because the command is altered with these framework files, etc.

Cross compilation is not the best solution? Ok then, I'll only make the game for Mac and then not get popular, users to hate me, etc. because they all use Windows or Linux.

A ton of games use C++, especially using SFML or OpenGL, and they are all cross-platform (just like League of Legends, their core game is made in C++, and even Clash of Clans, frameworks? On a mobile device?) Please help me out here. I want to be successful, and I might even leave SFML because of how it works, and it's poor cross-compilation support.

UPDATE: I got it working! Here's what I did:

I deleted Eclipse for C/C++ and I installed the newest version of Xcode. Once I did that, I followed the SFML documentation on installing it on Mac with Xcode thoroughly. Once that was done, I was able to build and run my project successfully, and I even found a .app file inside after building it. Thanks for your help!

Now, what about supporting Windows and Linux as well?
« Last Edit: April 12, 2015, 01:31:17 am by Enchanted Dragon »

Hiura

  • SFML Team
  • Hero Member
  • *****
  • Posts: 4321
    • View Profile
    • Email
Re: Compiling SFML on Mac OS X - Help
« Reply #3 on: April 12, 2015, 11:41:38 am »
Yes, there are quite some confusion, indeed.  ;)

Quote
I would rather not set up a virtual machine, as the performance is slow, it's a waste of time (especially downloading the iso file, it takes an HOUR), and it takes storage/memory off of my main hard drive.

Well, do something else while it downloads. You'll see (below) that VMs are much more useful than what you thing. It's an expense (space & time) that should not demotivate you.

Quote
Also, I would prefer not to use Xcode, because it asks me to make some kind of specific application, such as a command-line tool, cocoa application, game, etc. which I dislike.

Xcode is like eclipse: it build your project according to some rules. It is not limited to Objective-C application, iOS apps, ... You just need to find the right template for your project and since -- as you now know -- we provide a SFML template for Xcode you should be fine.

Quote
Also, eclipse is more popular
No, not really. At least not in the C++ community.

Quote
and I don't know why it isn't documented in the SFML docs.
Because in the end this has nothing to do with SFML itself. Like all other libraries out there, using SFML in eclipse should follow a standard procedure. And since on Mac very few people use it to develop C++ application writing a tutorial about it is not on our todo list. Eclipse's manual should be sufficient.

Quote
The fact that SFML uses "frameworks" makes it really hard to use
This statement is wrong: SFML on Mac can be build as dylibs or as frameworks, but at the end of the day they are the same. It's just a standard way of putting binary code together and has nothing to do with C++ itself since it's all assembly down there.

Quote
I don't want to have to make them install a bunch of framework files and put them somewhere, i want them to just be able to run the application.
In every case your user must install your application dependencies in order to run it: from simple image files to binaries. There's no magic here. It will be the same with all programming languages.

Now, some OS (such as OS X) support "application bundles" which can contain all your application's dependencies. That's what the Xcode template generate for you. But this .app file is in fact not a file but a directory (or an archive).

On some other systems the strategy is different. Users download an installer that will put your application and its dependency in the right place on the user file system. That's basically what deb file are on debian.

Quote
I'm starting to hate [C++] in fact, because of it's low cross platform support.
You have some misconception on how C++ works. The C++ language, in itself, is plateforme independent. Which means that a C++ application can be compiled and run on any plateforme as long as you have a C++ compiler on that plateforme. Also, unlike Java, you cannot compile your app on plateforme A and run it on plateforme B (easily) simply because the binary is not compatible. (Actually, Java will compile the byte code at runtime so it kind of works the same way except it has some intermediary representation.)

Quote
Cross compilation is not the best solution?
Cross compilation is a specific term meaning you want to compile your application on plateforme A but run it on plateforme B. SFML is multi-platform which means you can compile and use it on every (major) OSes. This does not imply that cross compilation is easy. (You should probably read this article.)

Quote
I deleted Eclipse for C/C++ and I installed the newest version of Xcode. Once I did that, I followed the SFML documentation on installing it on Mac with Xcode thoroughly. Once that was done, I was able to build and run my project successfully, and I even found a .app file inside after building it.
Good!

Quote
Now, what about supporting Windows and Linux as well?
The strategy is simple: you write your application in a cross plateforme manner (i.e. don't use plateforme specific code) and compile it on every OS with their proper compiler (i.e. follow the tutorial for Linux/Windows).
SFML / OS X developer

 

anything